views:

158

answers:

2

I have a class that implements ISelectionListener. I want to determine when the user right clicked when the selection was made.

This is the method that I need to implement to handle selection changes:

public void selectionChanged(IWorkbenchPart part, ISelection selection) { //HOW? // if right clicked... do something // else .. do default }

+3  A: 

I'm affraid you can't with this interface: a selection might be made with the keyboard. If you're trying to add an action to the context menu, see this tutorial.

Jerome
+1  A: 

The selection event doesn't have the information you need but you can register a mouse listener, and set an internal flag when the right button is pressed and clear the flag when it is released. In your selection listener, you can then check this flag.

Aaron Digulla
I thought of this but the problem is that I'm not guaranteed of the order in which these events are going to be executed. Example: I might raise the flag after the SelectionChange event occurs.
Craig
It seems that I will need to hack... :(
Craig
Seems like the timing isn't an issue...
Craig