1
$\begingroup$

I am having an issue where Mouseover doesn't work with Speak and instead returns Null. All of the examples below have failed. I am looking for an example that works with MouseOver and not with EventHandler.

With[{s := Speak["warning"]}, Mouseover["text", s]]

DynamicModule[{s = Speak["warning"]}, Mouseover["text", s]] 

With[{s := Speak["warning"]}, 
 Dynamic@If[CurrentValue["MouseOver"], s, "Hello World"]]

This following works ok, but is not what I am looking for.

EventHandler["Text", {"MouseClicked" :> Speak["warning"]}]
$\endgroup$
  • 1
    $\begingroup$ With[{s := Speak["warning"]}, Dynamic@If[CurrentValue["MouseOver"], s, "text"]] works in v9. $\endgroup$ – kglr Oct 16 '18 at 17:32
1
$\begingroup$

Both of those work:

EventHandler["Text", "MouseEntered" :> Speak["Kuba"]]

Button["Text", Speak["Kuba"], AutoAction -> True, Appearance -> None]

You get Null because it is what Speak evaluates to, iyou would need to follow it with ; "Text" to see it. Mouseover won't work because it will not hold its arguments and even if you put Dynamic around the second argument it will probably be cached and run once. So either of those two solutions above or the one proposed by kglr will work for you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.