Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2014

[Date Index] [Thread Index] [Author Index]

Search the Archive

EventHandler and keyboard events

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132365] EventHandler and keyboard events
  • From: Fred Simons <f.h.simons at tue.nl>
  • Date: Sat, 22 Feb 2014 03:05:13 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

The following is a simple event handler:

DynamicModule[{n=0},
Style[EventHandler[ Graphics[{Inset[Dynamic[n],{0,0}]}, ImageSize->100, 
Background->Yellow],
{ {"KeyDown","1"}:>(n=RandomInteger[{1,100}]), "KeyDown"->Null} ], 
ShowSelection->False]]

It works only when we first click on the yellow square, thereby making 
the current selection inside the event expression. When the current 
selection is outside the yellow square, typing a 1 replaces the current 
selection by 1, as usual.

My goal is to develop a DynamicModule such that pressing a key when the 
mouse is over the DynamicModule initiates some action, without first 
having to set the selection inside the DynamicModule. So in the above 
example I want to achieve that moving the mouse over the yellow square 
automatically sets the current selection within the yellow square. Can 
that be done in Mathematica?

My feeling is that it must be possible. After all, the frontend is able 
to detect that the mouse is over a displayed expression, e.g. in the 
function Mouseover, and setting the current selection in a notebook is a 
frontend action as well.

All thoughts are highly welcomed.

Fred Simons
Eindhoven University of Technology



  • Prev by Date: Drag-and-drop pdf files
  • Next by Date: Some linear constraints seem to be ignored in function NMinimize with
  • Previous by thread: Re: Drag-and-drop pdf files
  • Next by thread: Some linear constraints seem to be ignored in function NMinimize with