Catching keyboard with #keyPress

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Catching keyboard with #keyPress

talios@gmail.com
I've added a handler for #keyPress:  but don't seem to see anywhere to
get the keyboard modifiers, Ctrl and Shift seem to trigger #keyPress as
keys in their own right, which doesn't seem correct.  What I want is to
trap the user pressing ctrl+enter at the same time...

Mark


Reply | Threaded
Open this post in threaded view
|

Re: Catching keyboard with #keyPress

Schwab,Wilhelm K
Mark,

> I've added a handler for #keyPress:  but don't seem to see anywhere to
> get the keyboard modifiers, Ctrl and Shift seem to trigger #keyPress as
> keys in their own right, which doesn't seem correct.  What I want is to
> trap the user pressing ctrl+enter at the same time...

Two thoughts, neither of which is guaranteed to be helpful:

One of the more common mistakes is to mis-spell a selector.  If you
register interest in something that is not triggered, you won't get
events.  Ditto if you register interest with the wrong event source.

You are also possibly getting into an argument with Microsoft.
Control+enter might be swallowed by the view before Dolphin ever sees
it??  Another possibility is that it might be considered a virtual key,
and handled separately.

Have a good one,

Bill


--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Catching keyboard with #keyPress

Blair McGlashan-3
In reply to this post by talios@gmail.com
"Mark Derricutt" <[hidden email]> wrote in message
news:ck291a$[hidden email]...
> I've added a handler for #keyPress:  but don't seem to see anywhere to get
> the keyboard modifiers, Ctrl and Shift seem to trigger #keyPress as keys
> in their own right, which doesn't seem correct.

That's just the way Windows transmits keyboard events.

>...What I want is to trap the user pressing ctrl+enter at the same time...

When you receive an enter key press you can check if one of the modifiers is
pressed down like this:

    Keyboard default isCtrlDown

You can check for Shift and Alt in a similar way. See the Keyboard class.

It may also be that what you really want to do is to define an
accelerator/shortcut key. This is usually done by associating a key press
with a command accessible from the menu bar, but it is also possible to
define additional accelerator combinations that are not on any menus - start
browsing from Presenter>>additionalAccelerators to understand the full
mechanism, but usually if you don't care about these being user configurable
you just need to add a #defaultAdditionalAccelerator method on the class
side of your presenter. You can browse the existing implementations of this
to see how.

Regards

Blair