Alex Rivera | Logout

Mouseover & Dynamic in Mathematica

Asked 2011-11-29T22:32:22.720
14

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.

Edit
Report

1 Answer

7

A quick check shows that Mouseover evaluates all the expressions inside of it when you first launch it:

Mouseover[Print["One"]; 1, Print["Two"]; 2]

The idiomatic way of actually making the Mouseover modify the values of x is to use MouseAnnotation. Mr. Wizard's answer describes how to achieve this.

answered 2011-11-29T22:52:41.860

Your Answer