|
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   |
Eclipse User |
|
|
|
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 #332555 is a reply to message #332552] |
Tue, 28 October 2008 15:44   |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.04041 seconds