| Summary: | Multiple menu items get triggered via keyboard if items have no mnemonics | ||
|---|---|---|---|
| Product: | [RT] RAP | Reporter: | John Gymer <jgymer> |
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 3.0 | ||
| Target Milestone: | 3.1 M2 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| See Also: | https://git.eclipse.org/r/#/c/56411/ | ||
| Whiteboard: | sr302 | ||
Fixed in master with change https://git.eclipse.org/r/#/c/56411/ Backported to 3.0-maintenance branch with change https://git.eclipse.org/r/#/c/65095/ |
If some menu items have mnemonics defined, but others don't, it is possible to have multiple menu items selection event triggers on a single keypress. For example, here is a simple Edit menu: Edit -> Cut (no mnemonic) -> Copy (no mnemonic) -> Pa&ck Up (mnenonic in 'C') With focus on the Edit menu, pressing 'C' will trigger selection events for ALL THREE menu items! Here is a snippet to reproduce the behaviour: /* DEMONSTRATES Mnemonic issue - multiple menu items get triggered */ package bug.snippet; import org.eclipse.rap.rwt.RWT; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class Bugsy { Display display; Shell shell; Label lab; public void begin() { display = new Display(); display.setData(RWT.MNEMONIC_ACTIVATOR, "CTRL+ALT"); shell = new Shell(display, SWT.APPLICATION_MODAL|SWT.CLOSE); shell.setFullScreen(true); shell.setText("My Shell"); FormLayout layout = new FormLayout(); shell.setLayout(layout); FormData fd; Text myField = new Text(shell, SWT.BORDER|SWT.SINGLE); myField.setText(""); myField.setMessage("Press CTRL+ALT + E to get to the Edit menu, then press 'C'"); fd = new FormData(); fd.left = new FormAttachment(0, 10); fd.top = new FormAttachment(0, 50); fd.right = new FormAttachment(100,-10); fd.bottom = new FormAttachment(0, 80); myField.setLayoutData(fd); Menu myMenu = new Menu(shell, SWT.BAR); MenuItem miEdit = new MenuItem(myMenu, SWT.CASCADE); miEdit.setText("&Edit"); Menu editMenu = new Menu(miEdit); miEdit.setMenu(editMenu); MenuItem miCopy = new MenuItem(editMenu, SWT.NONE); miCopy.setText("Copy"); MenuItem miCut = new MenuItem(editMenu, SWT.NONE); miCut.setText("Cut"); MenuItem miPackUp = new MenuItem(editMenu, SWT.NONE); miPackUp.setText("Pa&ck Up"); miCopy.addSelectionListener(listener); miCut.addSelectionListener(listener); miPackUp.addSelectionListener(listener); shell.setMenuBar(myMenu); shell.open(); } public SelectionListener listener = new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { System.out.println("menuSelection.defaultSelected: " + e); } @Override public void widgetSelected(SelectionEvent e) { System.out.println("menuSelection.selected: " + e); } }; }