Question

Using SWT, what is the common way to indicate that a menu item (from a taskbar menu) is the currently active selection? Checkmark? Bold? How is this done with code?

Was it helpful?

Solution

Use the CHECK style during instantiation:

MenuItem menuItem = new MenuItem(menu, SWT.CHECK);

Use getSelection to check status:

boolean isSelected = menuItem.getSelection();

OTHER TIPS

org.eclipse.swt.widgets.MenuItem setSelection(true) / getSelection()

The style of the selection depends on the style of the menu item: CHECK, CASCADE, PUSH, RADIO, SEPARATOR, as in:

alt text
(source: developpez.com) alt text
(source: developpez.com)

MenuItem.getSelection()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top