Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 413203

Summary: Mnemonic on top level menu item does not fire selection event
Product: [RT] RAP Reporter: Sebastian Habenicht <dev>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tbuschto
Version: 2.1Flags: tbuschto: review+
Target Milestone: 2.2 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard: sr211

Description Sebastian Habenicht CLA 2013-07-17 15:45:58 EDT
since fix of this bug [1] firing selection events on top level menu items is supported. However, the selection event is still not fired when using mnemonics on the top level menu item.

In SWT, the following snippet fires the selection event for both menu items ("&Submenu" and "&Top Level Menu Item") when using the mnemonics. In RWT only "&Submenu" is selected:

        @Override
	protected void createContents(final Composite parent) {
		// define mnemonic activator and create menu bar
		getShell().getDisplay().setData(RWT.MNEMONIC_ACTIVATOR, "CTRL+ALT");
		final Menu menuBar = new Menu(getShell(), SWT.BAR);

		// create cascading menu item
		final MenuItem cascadeMenuItem = createMenuItem(menuBar, SWT.CASCADE, "&Cascade Menu Item");

		// create sub menu item of cascading menu item
		final Menu submenu = new Menu(getShell(), SWT.DROP_DOWN);
		cascadeMenuItem.setMenu(submenu);
		createMenuItem(submenu, SWT.PUSH, "&Submenu");

		// create top level menu item
		createMenuItem(menuBar, SWT.PUSH, "&Top Level Menu Item");

		// set menu bar to shell
		getShell().setMenuBar(menuBar);
	}


	private static MenuItem createMenuItem(final Menu parent, final int style, final String text) {
		final MenuItem menuItem = new MenuItem(parent, style);
		menuItem.setText(text);
		menuItem.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(final SelectionEvent e) {
				System.out.println("Selected item: " + text);
			}
		});
		return menuItem;
	}


Regards,
Sebastian


PS: Id in forum: 490285
Comment 1 Ivan Furnadjiev CLA 2013-07-19 05:19:19 EDT
Fixed with commit 6ae461fdceccbf751a1c0a9e8d1c061da632af3e.
Comment 2 Sebastian Habenicht CLA 2013-07-25 05:30:13 EDT
(In reply to comment #1)
> Fixed with commit 6ae461fdceccbf751a1c0a9e8d1c061da632af3e.

Hi Ivan,

is there any chance to have this fix in the service release 2.1.1 or 2.1.2? Since keyboard control in applications is a very important functionality it would be great to provide full mnemonics menu control with 2.1 instead of waiting a year for 2.2.

Thank you,
Sebastian
Comment 3 Ivan Furnadjiev CLA 2013-07-25 06:17:03 EDT
I've marked it for 2.1.1 consideration.
Comment 4 Tim Buschtoens CLA 2013-08-12 07:36:20 EDT
While the changes aren't trivial, I'll approve since it seems to reduce complexity instead of adding. +1 for SR211
Comment 5 Ivan Furnadjiev CLA 2013-08-13 04:05:49 EDT
Backported to 2.1-maintenance branch with commit 1df900d261b84f9397ad600bc82c98fc1b791c91.