|
Re: How to display the command's drop-down menu after the command icon is clicked? [message #1062942 is a reply to message #1062907] |
Tue, 11 June 2013 13:47 |
|
We had to do the same thing on our project, and it's pretty simple. All you have to do is add a handler to your pulldown command. Our execute method looks like this:
// Sanity check.
if ( null == event ) {
return null;
}
// Class check.
if ( ! ( event.getTrigger() instanceof Event ) ) {
return null;
}
Event eventWidget = (Event)event.getTrigger();
// Makes sure event came from a ToolItem.
if ( ! ( eventWidget.widget instanceof ToolItem ) ) {
return null;
}
ToolItem toolItem = (ToolItem)eventWidget.widget;
// Creates fake selection event.
Event newEvent = new Event();
newEvent.button = 1;
newEvent.widget = toolItem;
newEvent.detail = SWT.ARROW;
newEvent.x = toolItem.getBounds().x;
newEvent.y = toolItem.getBounds().y + toolItem.getBounds().height;
// Dispatches the event.
toolItem.notifyListeners( SWT.Selection, newEvent );
return null;
Mário Marinato
From Brazil
[Updated on: Tue, 11 June 2013 13:47] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02837 seconds