 
 
 
 
 
 
ButtonFunction for grid of custom Buttons
- To: mathgroup at smc.vnet.net
- Subject: [mg116333] ButtonFunction for grid of custom Buttons
- From: JohnH <ununquadium113 at yahoo.com>
- Date: Fri, 11 Feb 2011 04:15:44 -0500 (EST)
Module[{graphics, buttons, labels, myAction},
myAction[x_] :=
Print["Label: ", x];
labels = FromCharacterCode /@
((ToCharacterCode["A"][[1]] - 1) + Range[10]);
graphics = Graphics[{#, Disk[{0, 0}, 0.1]}] & /@ 
Take[ColorData[3,
"ColorList"], Length[labels]];
buttons = 
Button[First[#],
myAction[#] &, Appearance -> None] & /@ 
Transpose[{graphics,
labels}];
GraphicsGrid[Join[Partition[Riffle[labels, buttons], {8}]],
Frame -> None, 
ImageSize -> 225, Dividers -> {{True, {False,
True}}, All}]
]
I am trying to use custom Buttons to highlight different parts of a
graphic. I want the ButtonFunction for each button to do something
with the label associated with the button, but I can't figure out how
to do this. The output that I get from the sample if I click "D" above
is
	Label:
GraphicsBox[{RGBColor[0.541176,0.713725,0.027451],DiskBox[{0,0},0.1]}]
rather than "Label: D" as I want.
Any suggestions would be appreciated.

