Re: Dynamic Control of Graphics

• To: mathgroup at smc.vnet.net
• Subject: [mg105088] Re: Dynamic Control of Graphics
• From: dh <dh at metrohm.com>
• Date: Fri, 20 Nov 2009 06:40:38 -0500 (EST)
• References: <he0oae\$4ov\$1@smc.vnet.net>

```
PeterSF wrote:

> 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.

>

>

Hi Peter,

an event handler handles the whole region of the corresponding graphics

object. It can not distinguish between parts of it.

Daniel

```

• Prev by Date: Re: Dynamic Control of Graphics
• Next by Date: Re: Solve and the order of variables to solve for (v7.0)
• Previous by thread: Re: Dynamic Control of Graphics
• Next by thread: Re: Dynamic Control of Graphics