Reputation: 3742
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?
Upvotes: 4
Views: 7358
Reputation: 1329942
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:
(source: developpez.com)
(source: developpez.com)
Upvotes: 4
Reputation: 108979
Use the CHECK style during instantiation:
MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
Use getSelection to check status:
boolean isSelected = menuItem.getSelection();
Upvotes: 7