Mathematica and MouseListener - developing interactive graphics with Mma?

EventHandler can be used to catch various mouse events (mouse up, mouse down, mouse clicked, mouse dragged). Use MousePosition to add some intelligence.

EventHandler can be used to catch various mouse events (mouse up, mouse down, mouse clicked, mouse dragged). Use MousePosition to add some intelligence. Example: DynamicModule{col1 = Green, col2 = Blue}, Graphics { EventHandler Dynamic{col1, Disk}, ImageSize -> Tiny, {"MouseClicked" :> (col1 = col1 /.

{Red -> Green, Green -> Red})}, EventHandler Dynamic{col2, Disk{1, 1}}, ImageSize -> Tiny, {"MouseClicked" :> (col2 = col2 /. {Blue -> Yellow, Yellow -> Blue})} } The circles can be clicked independently. An action is defined for each object separately.

Amazingly, this even works for 3D Graphics: DynamicModule{col1 = Green, col2 = Blue}, Graphics3D { EventHandler Dynamic{col1, Sphere}, ImageSize -> Tiny, {"MouseClicked" :> (col1 = col1 /. {Red -> Green, Green -> Red})}, EventHandler Dynamic{col2, Sphere{1, 1, 1}}, ImageSize -> Tiny, {"MouseClicked" :> (col2 = col2 /. {Blue -> Yellow, Yellow -> Blue})} } .

1 Amazing. Thanks. – nilo de roock May 31 at 15:32 2 @ndroock1 Thanks for accepting my answer.

Next time you might wait a little longer so as to get more responses. – Sjoerd C. De Vries May 31 at 15:49 2 Sjoerd, I already voted for this, but I would vote again for the update.

I've never seen that before, rotatable and all. :-) – Mr.Wizard May 31 at 22:51 Why does the mouse tip, in the 3D case, do not pick a little arrow shape as would would expect when wanting to click on things? In the 2D example shown above, the tooltip at the end of the mouse on the screen is a little arrow, but not in the 3D case.

This is a little confusing to the user I think. – Nasser M. Abbasi Jun 1 at 3:02 @Nasser Nobody is perfect, I guess.

– Sjoerd C. De Vries Jun 1 at 5:49.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions