Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mouseover & Dynamic in Mathematica

Could anyone point out why this is not working in Mathematica 8:

DynamicModule[{x = Pink},
 Row[
  {Style["Hello", x],
   Mouseover[
    x = Green; "World",
    x = Blue; "World"]}]]

What I expect is to see the color of "Hello" change when I mouse over "World". What I am getting is a pink "Hello" that never changes color.

like image 349
gdelfino Avatar asked Nov 29 '11 22:11

gdelfino


People also ask

What is the use of mouseover?

The mouseover event is fired at an Element when a pointing device (such as a mouse or trackpad) is used to move the cursor onto the element or one of its child elements.

What is a mouseover definition?

A mouseover is an event that occurs in a Graphical User Interface (GUI) when the mouse pointer is moved over an object on the screen such as an icon, a button, text box, or even the edge of a window.

What is mouseover JavaScript?

mouseover is a special event which is related to the JavaScript and occurs whenever the mouse in pointer comes over an element. Each mouseover event occurs because they have some special property attached to the relatedTarget. mouseover property gets complimented with the target element of the mouseout event.


1 Answers

I think I have waited long enough to be fair. Here is my proposal:

DynamicModule[{x = Pink},
 Row[{
   Dynamic@Style["Hello", If[MouseAnnotation[] === 1, x = Green; Blue, x]],
   Annotation["World", 1, "Mouse"]
 }]
]
like image 90
Mr.Wizard Avatar answered Oct 04 '22 02:10

Mr.Wizard