Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Mnemonic on top level menu item(does not fire selection event)
Mnemonic on top level menu item [message #1068172] Fri, 12 July 2013 10:12 Go to next message
Sebastian Habenicht is currently offline Sebastian Habenicht
Messages: 10
Registered: January 2013
Junior Member
Hi all,

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;
	}

I would like to have the same behaviour with mnemonics as with mouse selection. Does anyone know of another way to do it?

I would suggest to implement the same behaviour in RWT, if possible.

Regards,
Sebastian


[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=397094

[Updated on: Fri, 12 July 2013 10:16]

Report message to a moderator

Re: Mnemonic on top level menu item [message #1069091 is a reply to message #1068172] Mon, 15 July 2013 02:39 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1793
Registered: July 2009
Senior Member
Hi Sebastian,
I can reproduce it with our Controls Demo + small changes. Please file a
bugzilla to track the progress on the issue.
Thanks,
Ivan

On 7/12/2013 5:12 PM, Sebastian Habenicht wrote:
> Hi all,
>
> 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" gets 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 + " " +
> e.item);
> }
> });
> return menuItem;
> }
>
> I would like to have the same behaviour with mnemonics as with mouse
> selection. Does anyone know of another way to do it?
> I would suggest to implement the same behaviour in RWT, if possible.
>
> Regards,
> Sebastian
>
>
> [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=397094

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Mnemonic on top level menu item [message #1070351 is a reply to message #1068172] Wed, 17 July 2013 15:50 Go to previous message
Sebastian Habenicht is currently offline Sebastian Habenicht
Messages: 10
Registered: January 2013
Junior Member
Thank you, Ivan, bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=413203

Regards,
Sebastian
Previous Topic:Listening to changes in Text caret position/selection
Next Topic:How to access user Principal without requiring authentication
Goto Forum:
  


Current Time: Wed Aug 20 16:31:14 EDT 2014

Powered by FUDForum. Page generated in 0.02926 seconds