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

Bug 301253

Summary: [Menu] Ignore accelerator in text
Product: [RT] RAP Reporter: Benjamin Muskalla <b.muskalla>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.3   
Target Milestone: 1.3 M6   
Hardware: All   
OS: All   
Whiteboard:

Description Benjamin Muskalla CLA 2010-01-29 09:37:30 EST
Currently we don't distinguish between item text and accelerator. I think we should ignore the accelerator the same way as we do it with mnemonics. As stated in the Javadoc of MenuItem#setText (which should be included too):

* Accelerator text is indicated by the '\t' character.
 * On platforms that support accelerator text, the text
 * that follows the '\t' character is displayed to the user,
 * typically indicating the key stroke that will cause
 * the item to become selected.  On most platforms, the
 * accelerator text appears right aligned in the menu.
 * Setting the accelerator text does not install the
 * accelerator key sequence. The accelerator key sequence
 * is installed using #setAccelerator.
 
 Snippet:
 Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));

Menu menuBar = new Menu(shell, SWT.BAR);
MenuItem fileMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
fileMenuHeader.setText("&File");

Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
fileMenuHeader.setMenu(fileMenu);

MenuItem fileSaveItem = new MenuItem(fileMenu, SWT.PUSH);
fileSaveItem.setText("&Save\tStrg+FOO");

shell.setMenuBar(menuBar);
	    
shell.pack();
shell.open();
while (!shell.isDisposed()) {
  if (!display.readAndDispatch())
    display.sleep();
}
display.dispose();
Comment 1 Ivan Furnadjiev CLA 2010-02-09 06:22:04 EST
The accelerator text is striped in MenuItemLCAUtil#writeImageAndText. Changes are in CVS HEAD.