Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Right click to select cell(how to get mouse right click to select a cell)
Right click to select cell [message #1103360] Fri, 06 September 2013 17:07 Go to next message
desis machino is currently offline desis machinoFriend
Messages: 10
Registered: May 2013
Junior Member
I would like to implement the behavior of a right click mouse event on nattable to select a cell much like the default behavior of the left click.

Could someone tell me how to do this or point me to some documentation/examples.

Thanks.
Re: Right click to select cell [message #1103383 is a reply to message #1103360] Fri, 06 September 2013 17:52 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Loom at the DefaultSelectionBindings. Additionally to create a binding for the left click you could implement the right click behaviour.
Re: Right click to select cell [message #1103397 is a reply to message #1103383] Fri, 06 September 2013 18:22 Go to previous messageGo to next message
desis machino is currently offline desis machinoFriend
Messages: 10
Registered: May 2013
Junior Member
Thanks Dirk,

Ive tried this approach in the following manner:

I am using the DefaultGridLayer with my NatTable. The DefaultGridLayer uses a DefaultBodyLayerStack which holds a SelectionLayer that is created with the default settings (uiBindings to listen to mouse left clicks events for selection logic).

I want to also allow users to right click to select cells, so in my layer (which extends the DefaultGridLayer), I've used addConfiguration to add a custom configuration (which extends AggregateConfiguration) in which I use addConfiguration to add a custom IConfiguration where in the configureUiBindings method, I've copied the code in DefaultSelectionBindings (in configureBodyMouseClickBindings) and basically replaced bodyLeftClick with bodyRightClick.

This is now working for me. Is this the correct way to implement such behavior?

But one thing that occurs is that the mouse click does not get propogated to open the context menu that I've configured.

What I would like to do is allow users to add bookmarks to rows on the grid. And they do so via a context menu option. And what I'd like, is if a user scrolls to a row they want, that they can just right click (without having to first left click to select the cell), and have the cell selected, and then the context menu open where they can choose to bookmark the row.

But when I implement as I've indicated above, the cell will be selected but the context menu will no longer open.

If I am doing this correctly and there is no way to get the context menu to appear, should I instead, select the cell from the context menu logic, where I could find the row/col position based on the mouse click event position and then continue the processing of the context menu?

Thanks
Re: Right click to select cell [message #1103412 is a reply to message #1103397] Fri, 06 September 2013 18:54 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
In this case you should create a custom action that performs the selection and after that open the context menu. And then bind that action to body right clicks
Previous Topic:How to change a natTable's structure?
Next Topic:Cell, row header, and column header selection not working in RCP app
Goto Forum:
  


Current Time: Thu Mar 28 19:34:50 GMT 2024

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

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

Back to the top