Craig
Craig

Reputation: 863

Eclipse RCP: Determine mouse button that caused selection on SelectionChanged Event

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 }

Upvotes: 0

Views: 877

Answers (2)

Aaron Digulla
Aaron Digulla

Reputation: 328556

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.

Upvotes: 1

Jerome
Jerome

Reputation: 8447

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.

Upvotes: 3

Related Questions