Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsDetecting keys while showing a context menu
https://www.eclipse.org/forums/index.php/mv/msg/487922/1060156/#msg_1060156
Is there a way to detect which key (or better accelator Ctrl, Shift or
Alt) during a right click on a control?
I have tried attaching a SWT.KeyDown listener on a Menu Widget, but no
event comes in.
I would appreciate, if someone has done this and could hint me. The use
case is to have differentiate the action for a MenuItem depending on if
Ctrl is pressed.
Thank You,
Christophe Bouhier]]>Christophe Bouhier2013-05-23T11:20:14-00:00Re: Detecting keys while showing a context menu
https://www.eclipse.org/forums/index.php/mv/msg/487922/1060196/#msg_1060196
/**
* The state of the keyboard modifier keys at the time
* the event was generated.
*/
public int stateMask;
]]>Vijay Raj2013-05-23T13:09:12-00:00Re: Detecting keys while showing a context menu
https://www.eclipse.org/forums/index.php/mv/msg/487922/1060202/#msg_1060202
> When you get a selection event on a menu item, the SelectionEvent object
> contains a variable called stateMask, this represents the keybord states
> if any..
>
> /**
> * The state of the keyboard modifier keys at the time
> * the event was generated.
> */
> public int stateMask;
Great, this could be usefull. I am afraid however this gets lost on the
JFace abstraction of a SelectionChangedEvent. Are there any ways around
this? (CC Jface forum)
*** from StructuredViewer
/**
* Handles a select event from the widget.
* <p>
* This method is internal to the framework; subclassers should not call
* this method.
* </p>
*
* @param event
* the SWT selection event
*/
protected void handleSelect(SelectionEvent event) {
// handle case where an earlier selection listener disposed the control.
Control control = getControl();
if (control != null && !control.isDisposed()) {
updateSelection(getSelection());
}
}
>]]>Christophe Bouhier2013-05-23T13:33:15-00:00Re: Detecting keys while showing a context menu
https://www.eclipse.org/forums/index.php/mv/msg/487922/1060398/#msg_1060398
Is it a table viewer or any jface viewer?
one possibility is that you can get the actual table or control from the viewer and add a selection listener , so that you can capture that mask and use it in your actual jface selection change event.]]>Vijay Raj2013-05-24T13:25:03-00:00