pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Bartlett <cbartlet...@gmail.com>
Subject Re: Problem with menu keyboard shortcut
Date Fri, 24 Sep 2010 08:51:13 GMT
A.J.

If your Application implements the Application.UnprocessedKeyHandler
interface, the relevant keyTyped/keyPressed/KeyReleased method will be
called by ApplicationContext when there is no focused component.  (As you
can see from the code you quoted)

I think you should be able to catch the keystrokes in the
UnprocessedKeyHandler.keyXXX methods, pull the relevant Action from the
ActionMapping and execute it.

http://svn.apache.org/repos/asf/pivot/tags/v1.5.1/wtk/src/org/apache/pivot/wtk/Application.java

Regards,

Chris

On 24 September 2010 14:22, A. J. <ozbtech@gmail.com> wrote:

> Hi,
> I'm trying to enable keyboard shortcuts for my app which have menu items.
> I have followed the steps described in doc (add keystroke,
> actionmapping to the window) but the actions do not get executed when
> pressing the corresponding keyboard shortcut.
> After looking in Pivot's code, I found out that the actions are
> executed only if a component in the application has the focus:
>
> class ApplicationContext :
> ...
>                        try {
> ==>                        if (focusedComponent == null) {
>                                if (application instanceof
> Application.UnprocessedKeyHandler) {
>                                    Application.UnprocessedKeyHandler
> unprocessedKeyHandler =
>
> (Application.UnprocessedKeyHandler)application;
>
> unprocessedKeyHandler.keyReleased(keyCode, keyLocation);
>                                }
>                            } else {
>                                if (!focusedComponent.isBlocked()) {
> ==>                                    consumed =
> focusedComponent.keyReleased(keyCode, keyLocation);
>                                }
>                            }
>
> ...
>
> The problem is that my app starts with a blank window with no focused
> component ...
> I don't want to add a component just to "enable" keyboard shortcuts in my
> app.
>
> What do you think ?
>
> Regards,
> A.J.
>

Mime
View raw message