You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Abbas Hussain <fa...@gmail.com> on 2010/10/15 12:56:27 UTC

Problem with Keystrokes not getting registered.

Hello All.
New to using Apache Pivot. Seems interesting and I am evaluating it for a
new project we are about to start. I have the following wtkx defined:
<Frame title="4SiJte" maximized="true"
        styles="{showWindowControls:false}"
        xmlns:wtkx="http://pivot.apache.org/wtkx"
        xmlns:content="org.apache.pivot.wtk.content"
        xmlns="org.apache.pivot.wtk">
    <actionMappings>
        <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
    </actionMappings>
    <menuBar>
        <MenuBar>
            ...
                <Menu.Item action="loginAction">
                     <buttonData>
                           <content:MenuItemData text="Login"
keyboardShortcut="CTRL-L" />
                     </buttonData>
           ...
    </menuBar>
I am reading it in to a Window, however, when I click on the action through
the menu item the action gets invoked, but pressing CTRL+L has no effect.
Any thoughts? I read through the tutorial but I am not sure what I am
missing here. The MenuBar tutorial seems to work fine and I am not sure what
I am doing differently.
On a different but related note, how do I setup menu accelerator keys? For
instance how pressing ALT+F usually shows the File menu in most apps.
Thanks,
A.Hussain.

Re: Problem with Keystrokes not getting registered.

Posted by Abbas Hussain <fa...@gmail.com>.
Greg,
I did that - however, to no effect. Here is the code from the startup method
in my app: http://pastebin.org/203997
<http://pastebin.org/203997>The variable app is a singleton object for the
Application class.
This is the code for the Action: http://pastebin.org/204256 However, the
sysout on line 4 never gets invoked by a keyboard shortcut. Only works with
the Menu though.

Thanks,
A.Hussain.

On Fri, Oct 15, 2010 at 4:58 PM, Greg Brown <gk...@mac.com> wrote:

> In order for a keystroke to be processed, a component must have the focus
> to receive the key event and propagate it up the component hierarchy to the
> window. Easiest way to handle this is to call requestFocus() on the window
> immediately after you open it.
>
> On Oct 15, 2010, at 6:56 AM, Abbas Hussain wrote:
>
> Hello All.
> New to using Apache Pivot. Seems interesting and I am evaluating it for a
> new project we are about to start. I have the following wtkx defined:
> <Frame title="4SiJte" maximized="true"
>         styles="{showWindowControls:false}"
>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>         xmlns:content="org.apache.pivot.wtk.content"
>         xmlns="org.apache.pivot.wtk">
>     <actionMappings>
>         <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
>     </actionMappings>
>     <menuBar>
>         <MenuBar>
>             ...
>                 <Menu.Item action="loginAction">
>                      <buttonData>
>                            <content:MenuItemData text="Login"
> keyboardShortcut="CTRL-L" />
>                      </buttonData>
>            ...
>     </menuBar>
> I am reading it in to a Window, however, when I click on the action through
> the menu item the action gets invoked, but pressing CTRL+L has no effect.
> Any thoughts? I read through the tutorial but I am not sure what I am
> missing here. The MenuBar tutorial seems to work fine and I am not sure what
> I am doing differently.
> On a different but related note, how do I setup menu accelerator keys? For
> instance how pressing ALT+F usually shows the File menu in most apps.
> Thanks,
> A.Hussain.
>
>
>

Re: Problem with Keystrokes not getting registered.

Posted by Mustafa Motiwala <mu...@gmail.com>.
Mnemonics! Thats the word!!! Sorry - english is not my native language (but
thats just an excuse) :-)
Hmmm... I think I might just do that.
Thanks for all your help! Appreciate it.
--abbas.

On Fri, Oct 15, 2010 at 8:59 PM, Greg Brown <gk...@mac.com> wrote:

> > Will this add an underscore to the letter indicating its an accelerator?
> Similarly, will I have to add it to buttons too? The idea being that a user
> should be able to do ALT+O to invoke the Ok button action. It would be a
> nice UI hint to the user if the O were underlined.
>
>
> Mnemonics are not currently supported. Feel free to submit a feature
> request for this if you would like.
>
>
>

Re: Problem with Keystrokes not getting registered.

Posted by Greg Brown <gk...@mac.com>.
> Will this add an underscore to the letter indicating its an accelerator? Similarly, will I have to add it to buttons too? The idea being that a user should be able to do ALT+O to invoke the Ok button action. It would be a nice UI hint to the user if the O were underlined. 


Mnemonics are not currently supported. Feel free to submit a feature request for this if you would like.



Re: Problem with Keystrokes not getting registered.

Posted by Abbas Hussain <fa...@gmail.com>.
On Fri, Oct 15, 2010 at 8:25 PM, Greg Brown <gk...@mac.com> wrote:

> > Yeh. I guess have to experiment with that feature. So any particular
> reason why the actions don't get registered at the time the window is
> created? I mean the Window does have the focus after all.
>
> The actions are registered when the window is created. The issue is that,
> while the AWT window has the focus, the Pivot window does not. In Pivot,
> keystrokes go directly to the component that has the focus and propagate up
> the component hierarchy from there. If no component has the focus, the Pivot
> window will never get keystrokes, even though the AWT window receives them,
> because there is no focused component to send them to.
>
> > Also, how do I have the shortcuts for the keyboard accelerators? Like how
> when we press the ALT+F key the File menu pops up on Firefox?
>
> It isn't built in but you should be able to add a global action mapping to
> do this.
>
Will this add an underscore to the letter indicating its an accelerator?
Similarly, will I have to add it to buttons too? The idea being that a user
should be able to do ALT+O to invoke the Ok button action. It would be a
nice UI hint to the user if the O were underlined.

Re: Problem with Keystrokes not getting registered.

Posted by Greg Brown <gk...@mac.com>.
> Yeh. I guess have to experiment with that feature. So any particular reason why the actions don't get registered at the time the window is created? I mean the Window does have the focus after all.

The actions are registered when the window is created. The issue is that, while the AWT window has the focus, the Pivot window does not. In Pivot, keystrokes go directly to the component that has the focus and propagate up the component hierarchy from there. If no component has the focus, the Pivot window will never get keystrokes, even though the AWT window receives them, because there is no focused component to send them to.

> Also, how do I have the shortcuts for the keyboard accelerators? Like how when we press the ALT+F key the File menu pops up on Firefox?

It isn't built in but you should be able to add a global action mapping to do this.



Re: Problem with Keystrokes not getting registered.

Posted by Abbas Hussain <fa...@gmail.com>.
Yeh. I guess have to experiment with that feature. So any particular reason
why the actions don't get registered at the time the window is created? I
mean the Window does have the focus after all.
Also, how do I have the shortcuts for the keyboard accelerators? Like how
when we press the ALT+F key the File menu pops up on Firefox?
--abbas.

On Fri, Oct 15, 2010 at 8:14 PM, Greg Brown <gk...@mac.com> wrote:

> Not entirely sure what you mean. Could you just combine the "welcome" and
> "login" screens into a single screen?
>
> On Oct 15, 2010, at 11:06 AM, Abbas Hussain wrote:
>
> Hmmm... can it be done so that I can have a Tab? The idea being that I
> display a "welcome" screen. That way I still have a focusable component and
> get the login action to work?
> Thanks,
> Abbas.
>
> On Fri, Oct 15, 2010 at 8:01 PM, Greg Brown <gk...@mac.com> wrote:
>
>> That's because Labels aren't focusable.  :-)  You need to add a component
>> that can get the focus, like a TextInput or PushButton.
>>
>> On Oct 15, 2010, at 10:55 AM, Abbas Hussain wrote:
>>
>> I added a Label on the frame inside the window, but still no luck.  I then
>> got a reference to the label and did a requestFocus on that but even that
>> did not work.
>>
>> --abbas.
>>
>> On Fri, Oct 15, 2010 at 5:50 PM, Greg Brown <gk...@mac.com> wrote:
>>
>>> Make sure that the window's content contains a focusable component.
>>>
>>> On Oct 15, 2010, at 8:25 AM, Abbas Hussain wrote:
>>>
>>> Greg,
>>> I did that - however, to no effect. Here is the code from the startup
>>> method in my app: http://pastebin.org/203997
>>>  <http://pastebin.org/203997>The variable app is a singleton object for
>>> the Application class.
>>> This is the code for the Action: http://pastebin.org/204256 However, the
>>> sysout on line 4 never gets invoked by a keyboard shortcut. Only works with
>>> the Menu though.
>>>
>>> Thanks,
>>> A.Hussain.
>>>
>>> On Fri, Oct 15, 2010 at 4:58 PM, Greg Brown <gk...@mac.com> wrote:
>>>
>>>> In order for a keystroke to be processed, a component must have the
>>>> focus to receive the key event and propagate it up the component hierarchy
>>>> to the window. Easiest way to handle this is to call requestFocus() on the
>>>> window immediately after you open it.
>>>>
>>>> On Oct 15, 2010, at 6:56 AM, Abbas Hussain wrote:
>>>>
>>>> Hello All.
>>>> New to using Apache Pivot. Seems interesting and I am evaluating it for
>>>> a new project we are about to start. I have the following wtkx defined:
>>>> <Frame title="4SiJte" maximized="true"
>>>>         styles="{showWindowControls:false}"
>>>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>>>         xmlns:content="org.apache.pivot.wtk.content"
>>>>         xmlns="org.apache.pivot.wtk">
>>>>     <actionMappings>
>>>>         <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
>>>>     </actionMappings>
>>>>     <menuBar>
>>>>         <MenuBar>
>>>>             ...
>>>>                 <Menu.Item action="loginAction">
>>>>                      <buttonData>
>>>>                            <content:MenuItemData text="Login"
>>>> keyboardShortcut="CTRL-L" />
>>>>                      </buttonData>
>>>>            ...
>>>>     </menuBar>
>>>> I am reading it in to a Window, however, when I click on the action
>>>> through the menu item the action gets invoked, but pressing CTRL+L has no
>>>> effect. Any thoughts? I read through the tutorial but I am not sure what I
>>>> am missing here. The MenuBar tutorial seems to work fine and I am not sure
>>>> what I am doing differently.
>>>> On a different but related note, how do I setup menu accelerator keys?
>>>> For instance how pressing ALT+F usually shows the File menu in most apps.
>>>> Thanks,
>>>> A.Hussain.
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Re: Problem with Keystrokes not getting registered.

Posted by Greg Brown <gk...@mac.com>.
Not entirely sure what you mean. Could you just combine the "welcome" and "login" screens into a single screen?

On Oct 15, 2010, at 11:06 AM, Abbas Hussain wrote:

> Hmmm... can it be done so that I can have a Tab? The idea being that I display a "welcome" screen. That way I still have a focusable component and get the login action to work?
> Thanks,
> Abbas.
> 
> On Fri, Oct 15, 2010 at 8:01 PM, Greg Brown <gk...@mac.com> wrote:
> That's because Labels aren't focusable.  :-)  You need to add a component that can get the focus, like a TextInput or PushButton.
> 
> On Oct 15, 2010, at 10:55 AM, Abbas Hussain wrote:
> 
>> I added a Label on the frame inside the window, but still no luck.  I then got a reference to the label and did a requestFocus on that but even that did not work.
>> 
>> --abbas.
>> 
>> On Fri, Oct 15, 2010 at 5:50 PM, Greg Brown <gk...@mac.com> wrote:
>> Make sure that the window's content contains a focusable component.
>> 
>> On Oct 15, 2010, at 8:25 AM, Abbas Hussain wrote:
>> 
>>> Greg,
>>> I did that - however, to no effect. Here is the code from the startup method in my app: http://pastebin.org/203997
>>> The variable app is a singleton object for the Application class.
>>> This is the code for the Action: http://pastebin.org/204256 However, the sysout on line 4 never gets invoked by a keyboard shortcut. Only works with the Menu though.
>>> 
>>> Thanks,
>>> A.Hussain.
>>> 
>>> On Fri, Oct 15, 2010 at 4:58 PM, Greg Brown <gk...@mac.com> wrote:
>>> In order for a keystroke to be processed, a component must have the focus to receive the key event and propagate it up the component hierarchy to the window. Easiest way to handle this is to call requestFocus() on the window immediately after you open it.
>>> 
>>> On Oct 15, 2010, at 6:56 AM, Abbas Hussain wrote:
>>> 
>>>> Hello All.
>>>> New to using Apache Pivot. Seems interesting and I am evaluating it for a new project we are about to start. I have the following wtkx defined:
>>>> <Frame title="4SiJte" maximized="true"
>>>>         styles="{showWindowControls:false}"
>>>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>>>         xmlns:content="org.apache.pivot.wtk.content"
>>>>         xmlns="org.apache.pivot.wtk">
>>>>     <actionMappings>
>>>>         <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
>>>>     </actionMappings>
>>>>     <menuBar>
>>>>         <MenuBar>
>>>>             ...
>>>>                 <Menu.Item action="loginAction">
>>>>                      <buttonData>
>>>>                            <content:MenuItemData text="Login" keyboardShortcut="CTRL-L" />
>>>>                      </buttonData>
>>>>            ...
>>>>     </menuBar>
>>>> I am reading it in to a Window, however, when I click on the action through the menu item the action gets invoked, but pressing CTRL+L has no effect. Any thoughts? I read through the tutorial but I am not sure what I am missing here. The MenuBar tutorial seems to work fine and I am not sure what I am doing differently.
>>>> On a different but related note, how do I setup menu accelerator keys? For instance how pressing ALT+F usually shows the File menu in most apps.
>>>> Thanks,
>>>> A.Hussain.
>>> 
>>> 
>> 
>> 
> 
> 


Re: Problem with Keystrokes not getting registered.

Posted by Abbas Hussain <fa...@gmail.com>.
Hmmm... can it be done so that I can have a Tab? The idea being that I
display a "welcome" screen. That way I still have a focusable component and
get the login action to work?
Thanks,
Abbas.

On Fri, Oct 15, 2010 at 8:01 PM, Greg Brown <gk...@mac.com> wrote:

> That's because Labels aren't focusable.  :-)  You need to add a component
> that can get the focus, like a TextInput or PushButton.
>
> On Oct 15, 2010, at 10:55 AM, Abbas Hussain wrote:
>
> I added a Label on the frame inside the window, but still no luck.  I then
> got a reference to the label and did a requestFocus on that but even that
> did not work.
>
> --abbas.
>
> On Fri, Oct 15, 2010 at 5:50 PM, Greg Brown <gk...@mac.com> wrote:
>
>> Make sure that the window's content contains a focusable component.
>>
>> On Oct 15, 2010, at 8:25 AM, Abbas Hussain wrote:
>>
>> Greg,
>> I did that - however, to no effect. Here is the code from the startup
>> method in my app: http://pastebin.org/203997
>>  <http://pastebin.org/203997>The variable app is a singleton object for
>> the Application class.
>> This is the code for the Action: http://pastebin.org/204256 However, the
>> sysout on line 4 never gets invoked by a keyboard shortcut. Only works with
>> the Menu though.
>>
>> Thanks,
>> A.Hussain.
>>
>> On Fri, Oct 15, 2010 at 4:58 PM, Greg Brown <gk...@mac.com> wrote:
>>
>>> In order for a keystroke to be processed, a component must have the focus
>>> to receive the key event and propagate it up the component hierarchy to the
>>> window. Easiest way to handle this is to call requestFocus() on the window
>>> immediately after you open it.
>>>
>>> On Oct 15, 2010, at 6:56 AM, Abbas Hussain wrote:
>>>
>>> Hello All.
>>> New to using Apache Pivot. Seems interesting and I am evaluating it for a
>>> new project we are about to start. I have the following wtkx defined:
>>> <Frame title="4SiJte" maximized="true"
>>>         styles="{showWindowControls:false}"
>>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>>         xmlns:content="org.apache.pivot.wtk.content"
>>>         xmlns="org.apache.pivot.wtk">
>>>     <actionMappings>
>>>         <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
>>>     </actionMappings>
>>>     <menuBar>
>>>         <MenuBar>
>>>             ...
>>>                 <Menu.Item action="loginAction">
>>>                      <buttonData>
>>>                            <content:MenuItemData text="Login"
>>> keyboardShortcut="CTRL-L" />
>>>                      </buttonData>
>>>            ...
>>>     </menuBar>
>>> I am reading it in to a Window, however, when I click on the action
>>> through the menu item the action gets invoked, but pressing CTRL+L has no
>>> effect. Any thoughts? I read through the tutorial but I am not sure what I
>>> am missing here. The MenuBar tutorial seems to work fine and I am not sure
>>> what I am doing differently.
>>> On a different but related note, how do I setup menu accelerator keys?
>>> For instance how pressing ALT+F usually shows the File menu in most apps.
>>> Thanks,
>>> A.Hussain.
>>>
>>>
>>>
>>
>>
>
>

Re: Problem with Keystrokes not getting registered.

Posted by Greg Brown <gk...@mac.com>.
That's because Labels aren't focusable.  :-)  You need to add a component that can get the focus, like a TextInput or PushButton.

On Oct 15, 2010, at 10:55 AM, Abbas Hussain wrote:

> I added a Label on the frame inside the window, but still no luck.  I then got a reference to the label and did a requestFocus on that but even that did not work.
> 
> --abbas.
> 
> On Fri, Oct 15, 2010 at 5:50 PM, Greg Brown <gk...@mac.com> wrote:
> Make sure that the window's content contains a focusable component.
> 
> On Oct 15, 2010, at 8:25 AM, Abbas Hussain wrote:
> 
>> Greg,
>> I did that - however, to no effect. Here is the code from the startup method in my app: http://pastebin.org/203997
>> The variable app is a singleton object for the Application class.
>> This is the code for the Action: http://pastebin.org/204256 However, the sysout on line 4 never gets invoked by a keyboard shortcut. Only works with the Menu though.
>> 
>> Thanks,
>> A.Hussain.
>> 
>> On Fri, Oct 15, 2010 at 4:58 PM, Greg Brown <gk...@mac.com> wrote:
>> In order for a keystroke to be processed, a component must have the focus to receive the key event and propagate it up the component hierarchy to the window. Easiest way to handle this is to call requestFocus() on the window immediately after you open it.
>> 
>> On Oct 15, 2010, at 6:56 AM, Abbas Hussain wrote:
>> 
>>> Hello All.
>>> New to using Apache Pivot. Seems interesting and I am evaluating it for a new project we are about to start. I have the following wtkx defined:
>>> <Frame title="4SiJte" maximized="true"
>>>         styles="{showWindowControls:false}"
>>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>>         xmlns:content="org.apache.pivot.wtk.content"
>>>         xmlns="org.apache.pivot.wtk">
>>>     <actionMappings>
>>>         <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
>>>     </actionMappings>
>>>     <menuBar>
>>>         <MenuBar>
>>>             ...
>>>                 <Menu.Item action="loginAction">
>>>                      <buttonData>
>>>                            <content:MenuItemData text="Login" keyboardShortcut="CTRL-L" />
>>>                      </buttonData>
>>>            ...
>>>     </menuBar>
>>> I am reading it in to a Window, however, when I click on the action through the menu item the action gets invoked, but pressing CTRL+L has no effect. Any thoughts? I read through the tutorial but I am not sure what I am missing here. The MenuBar tutorial seems to work fine and I am not sure what I am doing differently.
>>> On a different but related note, how do I setup menu accelerator keys? For instance how pressing ALT+F usually shows the File menu in most apps.
>>> Thanks,
>>> A.Hussain.
>> 
>> 
> 
> 


Re: Problem with Keystrokes not getting registered.

Posted by Abbas Hussain <fa...@gmail.com>.
I added a Label on the frame inside the window, but still no luck.  I then
got a reference to the label and did a requestFocus on that but even that
did not work.

--abbas.

On Fri, Oct 15, 2010 at 5:50 PM, Greg Brown <gk...@mac.com> wrote:

> Make sure that the window's content contains a focusable component.
>
> On Oct 15, 2010, at 8:25 AM, Abbas Hussain wrote:
>
> Greg,
> I did that - however, to no effect. Here is the code from the startup
> method in my app: http://pastebin.org/203997
>  <http://pastebin.org/203997>The variable app is a singleton object for
> the Application class.
> This is the code for the Action: http://pastebin.org/204256 However, the
> sysout on line 4 never gets invoked by a keyboard shortcut. Only works with
> the Menu though.
>
> Thanks,
> A.Hussain.
>
> On Fri, Oct 15, 2010 at 4:58 PM, Greg Brown <gk...@mac.com> wrote:
>
>> In order for a keystroke to be processed, a component must have the focus
>> to receive the key event and propagate it up the component hierarchy to the
>> window. Easiest way to handle this is to call requestFocus() on the window
>> immediately after you open it.
>>
>> On Oct 15, 2010, at 6:56 AM, Abbas Hussain wrote:
>>
>> Hello All.
>> New to using Apache Pivot. Seems interesting and I am evaluating it for a
>> new project we are about to start. I have the following wtkx defined:
>> <Frame title="4SiJte" maximized="true"
>>         styles="{showWindowControls:false}"
>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>         xmlns:content="org.apache.pivot.wtk.content"
>>         xmlns="org.apache.pivot.wtk">
>>     <actionMappings>
>>         <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
>>     </actionMappings>
>>     <menuBar>
>>         <MenuBar>
>>             ...
>>                 <Menu.Item action="loginAction">
>>                      <buttonData>
>>                            <content:MenuItemData text="Login"
>> keyboardShortcut="CTRL-L" />
>>                      </buttonData>
>>            ...
>>     </menuBar>
>> I am reading it in to a Window, however, when I click on the action
>> through the menu item the action gets invoked, but pressing CTRL+L has no
>> effect. Any thoughts? I read through the tutorial but I am not sure what I
>> am missing here. The MenuBar tutorial seems to work fine and I am not sure
>> what I am doing differently.
>> On a different but related note, how do I setup menu accelerator keys? For
>> instance how pressing ALT+F usually shows the File menu in most apps.
>> Thanks,
>> A.Hussain.
>>
>>
>>
>
>

Re: Problem with Keystrokes not getting registered.

Posted by Greg Brown <gk...@mac.com>.
Make sure that the window's content contains a focusable component.

On Oct 15, 2010, at 8:25 AM, Abbas Hussain wrote:

> Greg,
> I did that - however, to no effect. Here is the code from the startup method in my app: http://pastebin.org/203997
> The variable app is a singleton object for the Application class.
> This is the code for the Action: http://pastebin.org/204256 However, the sysout on line 4 never gets invoked by a keyboard shortcut. Only works with the Menu though.
> 
> Thanks,
> A.Hussain.
> 
> On Fri, Oct 15, 2010 at 4:58 PM, Greg Brown <gk...@mac.com> wrote:
> In order for a keystroke to be processed, a component must have the focus to receive the key event and propagate it up the component hierarchy to the window. Easiest way to handle this is to call requestFocus() on the window immediately after you open it.
> 
> On Oct 15, 2010, at 6:56 AM, Abbas Hussain wrote:
> 
>> Hello All.
>> New to using Apache Pivot. Seems interesting and I am evaluating it for a new project we are about to start. I have the following wtkx defined:
>> <Frame title="4SiJte" maximized="true"
>>         styles="{showWindowControls:false}"
>>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>>         xmlns:content="org.apache.pivot.wtk.content"
>>         xmlns="org.apache.pivot.wtk">
>>     <actionMappings>
>>         <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
>>     </actionMappings>
>>     <menuBar>
>>         <MenuBar>
>>             ...
>>                 <Menu.Item action="loginAction">
>>                      <buttonData>
>>                            <content:MenuItemData text="Login" keyboardShortcut="CTRL-L" />
>>                      </buttonData>
>>            ...
>>     </menuBar>
>> I am reading it in to a Window, however, when I click on the action through the menu item the action gets invoked, but pressing CTRL+L has no effect. Any thoughts? I read through the tutorial but I am not sure what I am missing here. The MenuBar tutorial seems to work fine and I am not sure what I am doing differently.
>> On a different but related note, how do I setup menu accelerator keys? For instance how pressing ALT+F usually shows the File menu in most apps.
>> Thanks,
>> A.Hussain.
> 
> 


Re: Problem with Keystrokes not getting registered.

Posted by Abbas Hussain <fa...@gmail.com>.
Greg,
I did that - however, to no effect. Here is the code from the startup method
in my app: http://pastebin.org/203997
<http://pastebin.org/203997>The variable app is a singleton object for the
Application class.
This is the code for the Action: http://pastebin.org/204256 However, the
sysout on line 4 never gets invoked by a keyboard shortcut. Only works with
the Menu though.

Thanks,
A.Hussain.

On Fri, Oct 15, 2010 at 4:58 PM, Greg Brown <gk...@mac.com> wrote:

> In order for a keystroke to be processed, a component must have the focus
> to receive the key event and propagate it up the component hierarchy to the
> window. Easiest way to handle this is to call requestFocus() on the window
> immediately after you open it.
>
> On Oct 15, 2010, at 6:56 AM, Abbas Hussain wrote:
>
> Hello All.
> New to using Apache Pivot. Seems interesting and I am evaluating it for a
> new project we are about to start. I have the following wtkx defined:
> <Frame title="4SiJte" maximized="true"
>         styles="{showWindowControls:false}"
>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>         xmlns:content="org.apache.pivot.wtk.content"
>         xmlns="org.apache.pivot.wtk">
>     <actionMappings>
>         <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
>     </actionMappings>
>     <menuBar>
>         <MenuBar>
>             ...
>                 <Menu.Item action="loginAction">
>                      <buttonData>
>                            <content:MenuItemData text="Login"
> keyboardShortcut="CTRL-L" />
>                      </buttonData>
>            ...
>     </menuBar>
> I am reading it in to a Window, however, when I click on the action through
> the menu item the action gets invoked, but pressing CTRL+L has no effect.
> Any thoughts? I read through the tutorial but I am not sure what I am
> missing here. The MenuBar tutorial seems to work fine and I am not sure what
> I am doing differently.
> On a different but related note, how do I setup menu accelerator keys? For
> instance how pressing ALT+F usually shows the File menu in most apps.
> Thanks,
> A.Hussain.
>
>
>

Re: Problem with Keystrokes not getting registered.

Posted by Greg Brown <gk...@mac.com>.
In order for a keystroke to be processed, a component must have the focus to receive the key event and propagate it up the component hierarchy to the window. Easiest way to handle this is to call requestFocus() on the window immediately after you open it.

On Oct 15, 2010, at 6:56 AM, Abbas Hussain wrote:

> Hello All.
> New to using Apache Pivot. Seems interesting and I am evaluating it for a new project we are about to start. I have the following wtkx defined:
> <Frame title="4SiJte" maximized="true"
>         styles="{showWindowControls:false}"
>         xmlns:wtkx="http://pivot.apache.org/wtkx"
>         xmlns:content="org.apache.pivot.wtk.content"
>         xmlns="org.apache.pivot.wtk">
>     <actionMappings>
>         <Window.ActionMapping action="loginAction" keyStroke="CTRL-L" />
>     </actionMappings>
>     <menuBar>
>         <MenuBar>
>             ...
>                 <Menu.Item action="loginAction">
>                      <buttonData>
>                            <content:MenuItemData text="Login" keyboardShortcut="CTRL-L" />
>                      </buttonData>
>            ...
>     </menuBar>
> I am reading it in to a Window, however, when I click on the action through the menu item the action gets invoked, but pressing CTRL+L has no effect. Any thoughts? I read through the tutorial but I am not sure what I am missing here. The MenuBar tutorial seems to work fine and I am not sure what I am doing differently.
> On a different but related note, how do I setup menu accelerator keys? For instance how pressing ALT+F usually shows the File menu in most apps.
> Thanks,
> A.Hussain.