Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16582

EventHandler and keyboard events

From Fred Simons <f.h.simons@tue.nl>
Newsgroups comp.soft-sys.math.mathematica
Subject EventHandler and keyboard events
Date 2014-02-22 07:47 +0000
Message-ID <le9kmi$ffs$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar


Thread

EventHandler and keyboard events Fred Simons <f.h.simons@tue.nl> - 2014-02-22 07:47 +0000

csiph-web