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 |
Sebastian Habenicht 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 |
Ivan Furnadjiev 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/
|
|
| |
Goto Forum:
Current Time: Fri Apr 19 02:31:51 GMT 2024
Powered by FUDForum. Page generated in 0.01933 seconds
|