Dynamic Control of Graphics

• To: mathgroup at smc.vnet.net
• Subject: [mg105019] Dynamic Control of Graphics
• From: PeterSF <caesarrenasci at gmail.com>
• Date: Wed, 18 Nov 2009 06:57:52 -0500 (EST)

```I am new to the dynamic features of the Mathematica fron end.  Having spent a
considerable amount of time, I am still strufggling with the following
problem: how to control dynamically individual elements of a combined graphics?
Specifically, we are given
Show[ Plot[ Sin[x], {x,0,Pi} ], Graphics[ { textColor, Text
["Test"] } ],
Graphics[ { lineWidth,
Line[{ {0,0}, {0,2}] } ] ]
The objective is to change:
* the color of text (the 2nd element) if and only if a mouse is
over that text;
* the thickness of the line (the 3rd element) if and only if a
mouse is
over that line.
I can see how to handle these simultaneously:

DynamicModule[ { lineWidth = Thin, textColor = Blue},
Dynamic @ EventHandler[ Show[ Plot[Sin[x], {x, 0, \[Pi]} ],
Graphics[{ textColor, Text["XXX", {1, 1}]}],
Graphics[{ lineWidth, Line[{{0, 0}, {2, 1}}]}]],
"MouseClicked" :> (textColor  = Red, lineWidth )]]

The question is, how can one control the wdth and the color
individually?

More broadly, I need to perform the following tasks: upon mouseover to
change the appearance of a single graphics element (line, text, etc.);
then, upon mouse click, to store in a variable which elements was
selected (clicked over); and, upon pressing of the Delete key, to
remove that element from the combined graphics.

I would be most greatful for any and all of the help you could give
me.
Peter.

```

• Prev by Date: How to instruct Math to take a certain (e.g. real) type of results
• Next by Date: aliases and hot keys
• Previous by thread: Re: How to instruct Math to take a certain (e.g. real) type of results
• Next by thread: Re: Dynamic Control of Graphics