MathGroup Archive 2013

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

Search the Archive

Re: Dynamically updated CurrentValue: I want to know which key is

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129454] Re: Dynamically updated CurrentValue: I want to know which key is
  • From: awnl <awnl at gmx-topmail.de>
  • Date: Mon, 14 Jan 2013 23:31:45 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <kcntv9$f8j$1@smc.vnet.net> <kcql13$lrl$1@smc.vnet.net> <kd03e8$6dh$1@smc.vnet.net>

Hi,
>>
>>
>> I think you are looking for "EventKey":
>>
>>
>>
>> EventHandler[Graphics@Rectangle[], {
>>
>> "KeyDown" :> Print[CurrentValue["EventKey"]]
>>
>> }]
>>
>>
>>
>> hth,
>>
>>
>>
>> albert
>
>
> But why not all keys are catched by "EventKey"? For example, pressing
> "a", "i", "o", "p" etc. does nothing. Why?
>

I don't know what exactly is the reason why it doesn't work for you. I 
can see three possible causes:

1) There are built in keyboard shortcuts which "eat up" what you type 
before the EventHandle will even see them, typical examples are things 
like Ctrl-C on Windows. Unfortunately I don't think there is a 
documented way to change that.

2) Many of the keys are only giving None for CurrentValue["EventKeys"], 
presumably WRI only has implemented the smallest common set available on 
all supported OS...

3) The selection state is not what it should be. With that respect my 
example using a Graphics is suboptimal as it needs some tricks to 
actually select the EventHandler and not the Graphics object. You might 
want to use something like EventHandler["hello", {"KeyDown" :> 
Print[CurrentValue["EventKey"]]}] instead, where putting the cursor 
within the hello does the right thing...

The following makes the Graphics example somewhat easier to use (just 
clicking into the graphic will make the selection such that the keyboard 
events are catched by the EventHandler):

EventHandler[
  Style[Graphics[Rectangle[]],
   Selectable -> False], {"KeyDown" :>
    MessageDialog[CurrentValue["EventKey"]]}
  ]


hth,

albert




  • Prev by Date: Iterative process for creating a B Spline Curve points
  • Next by Date: kalman filter understanding - one measurement two variables
  • Previous by thread: Re: Dynamically updated CurrentValue: I want to know which key is
  • Next by thread: Aligning graphics on frame boundaries