1

I already have a working ListViewer with items in it and a working context menu.

However when I right-click on the ListViewer the context menu opens without changing the active selection to the item that has been right-clicked. For example, if I have 3 items and the first one is currently selected, no matter where I right-click the selection will not change. What I intend is that when the first item is currently selected and I right-click the third item then the third item should get selected (resulting in the context menu referring to the third item).

I already found an answer that deals with this problem (although it is for a TreeViewer it should work similarly for a ListViewer), but the solution (using CursorLocation) seems very dirty. Here's the question/answer I mentioned: Jface TreeViewer add right click menu, depending on clicked node

Is there a more elegant way to also trigger a new selection on right-click?

Community
  • 1
  • 1
Max N.
  • 41
  • 7

0 Answers0