I want to simulate a click on a menu item but found no method. I'm thinking of something like doClick() of JMenu.
At the moment my very stupid solution looks like this:
private void performClick(MenuItem source, Event event) {
source.notifyListeners(SWT.Selection, event);
}
But maybe there's a better way to fire the event?
A MenuItem in SWT can be controlled by the method
addSelectionListener(SelectionListener listener)
The SelectionListener provides the method
public void widgetSelected(SelectionEvent arg0) {}
where you can include the desired functionality.
For a documentation to the Class Menu Item see:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.