Skip to main content


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 14:12 Go to next message
Sebastian Habenicht is currently offline Sebastian HabenichtFriend
Messages: 42
Registered: January 2013
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 14: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 06:39 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
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 19:50 Go to previous message
Sebastian Habenicht is currently offline Sebastian HabenichtFriend
Messages: 42
Registered: January 2013
Member
Thank you, Ivan, bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=413203

Regards,
Sebastian
Previous Topic:How to change the alignment image/text in a ToolItem?
Next Topic:branding body background
Goto Forum:
  


Current Time: Fri Apr 19 02:31:51 GMT 2024

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

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

Back to the top