Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15741

ButtonFunction for grid of custom Buttons

From JohnH <ununquadium113@yahoo.com>
Newsgroups comp.soft-sys.math.mathematica
Subject ButtonFunction for grid of custom Buttons
Date 2011-02-11 09:16 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ij2uor$7na$1@smc.vnet.net> (permalink)

Show all headers | View raw


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.

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

ButtonFunction for grid of custom Buttons JohnH <ununquadium113@yahoo.com> - 2011-02-11 09:16 +0000

csiph-web