Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Detecting keys while showing a context menu
Detecting keys while showing a context menu [message #1060156] Thu, 23 May 2013 11:20 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hello,

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
Re: Detecting keys while showing a context menu [message #1060196 is a reply to message #1060156] Thu, 23 May 2013 13:09 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
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;


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Detecting keys while showing a context menu [message #1060202 is a reply to message #1060196] Thu, 23 May 2013 13:33 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 23-05-13 15:09, Vijay Raj wrote:
> 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());
}
}
>
Re: Detecting keys while showing a context menu [message #1060398 is a reply to message #1060202] Fri, 24 May 2013 13:25 Go to previous message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
I thought you were talking about a menu or menu item,
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.


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Previous Topic:Merging cells in a Word table through OleAutomation
Next Topic:How to keep Popup-menu open after selection event?
Goto Forum:
  


Current Time: Sat Apr 20 01:04:31 GMT 2024

Powered by FUDForum. Page generated in 0.04057 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top