Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Re: Menu item accel key works only after menu item has been shown
Re: Menu item accel key works only after menu item has been shown [message #332551] Tue, 28 October 2008 13:21 Go to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Torsten Uhlmann wrote:
> Hi,
>
> I'm developing a SWT/JFace application using the libraries from Eclipse
> 3.4.1. I encounter the following problem on Windows (Vista 32bit) and
> Ubuntu 8.10 32bit:
>
> I create a menu bar in the createMenuManager method of the JFace
> ApplicationWindow. I add MenuManagers for file, edit and help.
>
> I then add an ExitAction to the file MenuManager like so:
>
> filemenu.add(new ExitAction(this));
>
> The ExitAction is defined this way:
>
> public class ExitAction extends Action {
> final ApplicationWindow window;
>
> public ExitAction(ApplicationWindow w) {
>
> this.window = w;
> setText("E&xit");
> setToolTipText("Exit the application");
> setAccelerator(SWT.MOD1 + 'Q'); }
> }
>
> Now when my application starts I want be able to press "CTRL+Q" to quit
> the application. This does however not work. Only AFTER I click on
> "File" in the menu bar and THEN clicking "CTRL+Q" the application will
> quit.
>
> I've tried this with different accelerators- same behavior.
>
> It does work however if I create a "MenuItem" instead of an "Action" to
> contribute to the menu bar.
>
> Is this a SWT bug or do I miss something?
>
> Torsten.

Re-directing JFace question


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Menu item accel key works only after menu item has been shown [message #332552 is a reply to message #332551] Tue, 28 October 2008 13:23 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Paul Webster wrote:
> Torsten Uhlmann wrote:
>> Hi,
>>
>> I'm developing a SWT/JFace application using the libraries from
>> Eclipse 3.4.1. I encounter the following problem on Windows (Vista
>> 32bit) and Ubuntu 8.10 32bit:
>>
>> I create a menu bar in the createMenuManager method of the JFace
>> ApplicationWindow. I add MenuManagers for file, edit and help.
>>
>> I then add an ExitAction to the file MenuManager like so:
>>
>> filemenu.add(new ExitAction(this));
>>
>> The ExitAction is defined this way:
>>
>> public class ExitAction extends Action {
>> final ApplicationWindow window;
>>
>> public ExitAction(ApplicationWindow w) {
>>
>> this.window = w;
>> setText("E&xit");
>> setToolTipText("Exit the application");
>> setAccelerator(SWT.MOD1 + 'Q'); }
>> }
>>
>> Now when my application starts I want be able to press "CTRL+Q" to
>> quit the application. This does however not work. Only AFTER I click
>> on "File" in the menu bar and THEN clicking "CTRL+Q" the application
>> will quit.
>>
>> I've tried this with different accelerators- same behavior.
>>
>> It does work however if I create a "MenuItem" instead of an "Action"
>> to contribute to the menu bar.
>>
>> Is this a SWT bug or do I miss something?
>>
>> Torsten.

By default the ApplicationWindow won't instantiate menus unless the user
clicks on them. One of the workarounds is to use
menuManager.updateAll(true) to force it to instantiate all of the
MenuItems (which is what allows SWT menu accelerators to work)

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Menu item accel key works only after menu item has been shown [message #332553 is a reply to message #332551] Tue, 28 October 2008 13:58 Go to previous messageGo to next message
Torsten Uhlmann is currently offline Torsten UhlmannFriend
Messages: 14
Registered: July 2009
Junior Member
Paul,

would you please comment on your comment?
Do I have to ask the question in a different forum or do you redirect the
question there.

In any case, which forum is it going to (I didn't find a jface forum).

Thanks,
Torsten.
Re: Menu item accel key works only after menu item has been shown [message #332555 is a reply to message #332552] Tue, 28 October 2008 15:44 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
Paul Webster wrote:
> Paul Webster wrote:
>> Torsten Uhlmann wrote:
>>> Hi,
>>>
>>> I'm developing a SWT/JFace application using the libraries from
>>> Eclipse 3.4.1. I encounter the following problem on Windows (Vista
>>> 32bit) and Ubuntu 8.10 32bit:
>>>
>>> I create a menu bar in the createMenuManager method of the JFace
>>> ApplicationWindow. I add MenuManagers for file, edit and help.
>>>
>>> I then add an ExitAction to the file MenuManager like so:
>>>
>>> filemenu.add(new ExitAction(this));
>>>
>>> The ExitAction is defined this way:
>>>
>>> public class ExitAction extends Action {
>>> final ApplicationWindow window;
>>>
>>> public ExitAction(ApplicationWindow w) {
>>>
>>> this.window = w;
>>> setText("E&xit");
>>> setToolTipText("Exit the application");
>>> setAccelerator(SWT.MOD1 + 'Q'); }
>>> }
>>>
>>> Now when my application starts I want be able to press "CTRL+Q" to
>>> quit the application. This does however not work. Only AFTER I click
>>> on "File" in the menu bar and THEN clicking "CTRL+Q" the application
>>> will quit.
>>>
>>> I've tried this with different accelerators- same behavior.
>>>
>>> It does work however if I create a "MenuItem" instead of an "Action"
>>> to contribute to the menu bar.
>>>
>>> Is this a SWT bug or do I miss something?
>>>
>>> Torsten.
>
> By default the ApplicationWindow won't instantiate menus unless the user
> clicks on them. One of the workarounds is to use
> menuManager.updateAll(true) to force it to instantiate all of the
> MenuItems (which is what allows SWT menu accelerators to work)

This must be a recent behavioral change and I wonder concerning
it's rational. By definition, an accelerator key combination
should activate the Action.run *without* any further user interaction
like mouse movements etc - it seems that Eclipse 3.4.x has killed
this useful behavior. Has pre-Eclipse-3.4 already behaved as if
menuManager.updateAll(true) had been applied??

- Daniel
Re: Menu item accel key works only after menu item has been shown [message #332559 is a reply to message #332555] Tue, 28 October 2008 18:58 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Daniel Krügler wrote:
> Paul Webster wrote:
>>
>> By default the ApplicationWindow won't instantiate menus unless the
>> user clicks on them. One of the workarounds is to use
>> menuManager.updateAll(true) to force it to instantiate all of the
>> MenuItems (which is what allows SWT menu accelerators to work)
>
> This must be a recent behavioral change and I wonder concerning
> it's rational. By definition, an accelerator key combination
> should activate the Action.run *without* any further user interaction
> like mouse movements etc - it seems that Eclipse 3.4.x has killed
> this useful behavior. Has pre-Eclipse-3.4 already behaved as if
> menuManager.updateAll(true) had been applied??

Initializing accelerators was a side effect of an over eager call in the
MenuManager, that was changed in 3.4 as part of
https://bugs.eclipse.org/bugs/show_bug.cgi?id=136397

Menu based accelerators only work if you forcefully create your entire
MenuItem structure.


There is a bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=243758
about its implications on JFace ApplicationWindow only.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Previous Topic:Getting the main Menu bar in Eclipse 3.3
Next Topic:Where to specify the name of the compiled *.war file?
Goto Forum:
  


Current Time: Sun Nov 03 12:14:02 GMT 2024

Powered by FUDForum. Page generated in 0.02983 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top