Reputation: 4419
Is there a way to detect a CTRL-click on a ToolItem? I want to distinguish between CTRL+Click and normal mouse click.
ToolBar toolbar= new ToolBar(parent, SWT.NONE);
ToolItem saveToolItem = new ToolItem(toolbar, SWT.PUSH);
...
saveToolItem.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
// if CTRL+Click {
// specialSave();
// } else
normalSave();
}));
Upvotes: 1
Views: 93
Reputation: 111217
The SelectionEvent
passed to the event (in e
in your code) has a stateMask
field including the modifier keys being pressed. The SWT.CTRL
constant for Ctrl.
So:
if ((e.stateMask & SWT.CTRL) == SWT.CTRL)
Tests for the Ctrl key being pressed
Upvotes: 1