Bug 35750

Summary: [Key Bindings] Accelerator Key doesn't work if items are added to Help menu
Product: [Eclipse Project] Platform Reporter: Masaki Wakao <wakao>
Component: UIAssignee: Chris McLaren <csmclaren>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P2 CC: kuroki, n.a.edgar, uchi
Version: 2.1   
Target Milestone: 2.1.1   
Hardware: PC   
OS: Windows All   
Whiteboard:
Attachments:
Description Flags
MultiPageEditorContributor.java none

Description Masaki Wakao CLA 2003-03-27 05:49:58 EST
Some accelerator doesn't work if an item is added under Help menu.

How to reproduce:

Prepare:
I just use "Plug-in project wizard" and select "Plug-in with a multi-page 
editor". Then add the following code to modify 
MultiPageEditorContributor#setActivePage().
---------------------------------------------
IMenuManager fm = actionBars.getMenuManager().findMenuUsingPath
(IWorkbenchActionConstants.M_HELP);
if (null != fm) {
	fm.removeAll();
	fm.setVisible(true);
	fm.add(new Separator());
}
actionBars.updateActionBars();
---------------------------------------------

Run:
1. Open the editor
2. switch to "Properties" page and go back to default page
3. try "Ctrl+A", "Ctrl+Z", "Ctrl+F"
Comment 1 Masaki Wakao CLA 2003-03-27 05:57:40 EST
Created attachment 4364 [details]
MultiPageEditorContributor.java
Comment 2 Masaki Wakao CLA 2003-03-27 05:59:21 EST
Comment on attachment 4364 [details]
MultiPageEditorContributor.java

Override the file onto output of "multi-page editor" of "plug-in project
wizard"
Comment 3 Masaki Wakao CLA 2003-03-27 07:22:40 EST
I checked this problem on R2.1RC1 and R2.1RC3b
Comment 4 Nick Edgar CLA 2003-03-28 14:18:14 EST
The key bindings mechanism internally uses hidden menu items in the last menu 
(i.e. the Help menu) to obtain accelerator keys.  This is due to an SWT 
limitation that prevents us from obtaining them in any other way.
Comment 5 Masaki Wakao CLA 2003-03-28 22:10:09 EST
Yes, I know the AcceleratorMenu is created as child of Help menu.
The problem is the menu is disposed when IActionBars#updateActionBars() is 
called if Help menu is dirty (Actually, MenuManager#update() disposes it).

The AcceleratorMenu is recreated in WWinKeyBindingService#updateAccelerators().
But the recreation happens only when the editor is deactivated. 
So, after the AcceleratorMenu is disposed, switching to another view and 
switching back to the editor activates accelerator again.

I think AcceleratorMenu recreation should be done while page changed.
In IActionBars#updateActionBars() or somewhere.

This problem is critical for our application because we have a lot of 
accelerators and we add a menu item under Help menu.
Comment 6 Nick Edgar CLA 2003-03-31 10:53:39 EST
Should investigate whether the AcceleratorMenu can be contributed by a 
ContributionItem, so that even if the menus are updated, it does not get 
omitted.
Comment 7 Masaki Wakao CLA 2003-04-13 21:57:37 EDT
Is there any workaroud for this problem ?
If nohing, I expect the problem will be fixed in 2.1.1.
Comment 8 Chris McLaren CLA 2003-05-13 15:26:32 EDT
fixed 2.1.1. changed MenuManager to not dispose any MenuItem containing a 
specific data object (via .setData(..)) shared by the AcceleratorMenu. this 
way no new API was required to bridge jface and workbench for this problem.
Comment 9 Tod Creasey CLA 2003-06-02 16:10:42 EDT
This problem still exists on GTK in build 20030530.
Comment 10 Chris McLaren CLA 2003-06-03 14:32:39 EDT
tried with M20030602 following exact steps. was not able to reproduce this problem. i am 
on mac osx. i've asked tod to retry on GTK, though platform should not be an issue here.  
reclosing as fixed, though we may see this again.. :)
Comment 11 Chris McLaren CLA 2003-06-04 10:44:36 EDT
verified on mac, tod verified on windows and gtk.