Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Using a SelectionLayer and buttons together in a table(Using a SelectionLayer and buttons together in a table)
Using a SelectionLayer and buttons together in a table [message #1740708] Wed, 17 August 2016 13:21 Go to next message
Lothar Lattermann is currently offline Lothar LattermannFriend
Messages: 26
Registered: July 2016
Junior Member
Hi,

with our table we are using a selection layer. In a next step we would like to use custom styled buttons in table cells (the button are not to fill our the complete cell).

However, we are having problems combining the two. We think a possible solution would be to:



    1) Register the selection layer
    2) Create an ICellPainter implementation for the button. The button can then be drawn as required.
    3) Create an IMouseAction action implementation which is registered on the nattable instance (can also be registered on the selection layer instance not clear what the difference is here)


The IMouseAction implementation is being wrapped in a configuration. It is vital that we are registered as the single click binding.
The mouse down binding is consumed by the selection layer because it is the first mouse binding on the stack. All we get then is a RowSelectionEvent which does not allow us the determine if the button was clicked.

If registered correctly the IMouseAction#run method will be called. The provided MouseEvent instance contains x/y coordinates of the click.


    4) With the received coordinates we can check if the click was inside of the button. If we receive a positive click we run some action.


Could somebody comment on this if this be feasible or sensible way to go? Is there an easier/better/smarter solution for this?


A sample implementation for buttons can be found in the Rendereing_a_cell_as_a_button example. The example does not use a selection layer however.


Kind Regards
Re: Using a SelectionLayer and buttons together in a table [message #1740806 is a reply to message #1740708] Thu, 18 August 2016 15:57 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2614
Registered: July 2012
Senior Member
You need to register your IMouseAction as first mouseDown binding. Then it will consume the mouse down event.
Re: Using a SelectionLayer and buttons together in a table [message #1740887 is a reply to message #1740806] Fri, 19 August 2016 11:49 Go to previous messageGo to next message
Lothar Lattermann is currently offline Lothar LattermannFriend
Messages: 26
Registered: July 2016
Junior Member
Ah, fantastic!

This is what we do:


  • we overwrite the selection binding for the selection layer and register the layer as the first single click action.
  • we register the button IMouseAction as the first mouse down binding (as you explained)


As a result we get the button pressed now with mouse down and the row will be selected with the click.

Thank you!
Re: Using a SelectionLayer and buttons together in a table [message #1740890 is a reply to message #1740887] Fri, 19 August 2016 12:52 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2614
Registered: July 2012
Senior Member
I don't think it is necessary to change the selection bindings if you register your bindings as firstxxx
Re: Using a SelectionLayer and buttons together in a table [message #1740903 is a reply to message #1740890] Fri, 19 August 2016 16:13 Go to previous message
Lothar Lattermann is currently offline Lothar LattermannFriend
Messages: 26
Registered: July 2016
Junior Member
Yes, for us, it is working but for the detail that the row does not get selected when one presses the button. If users click on another cell the row does get selected though. We changed the selection bindings because we want the 1st behaviour, i.e. the row should also be selected when the button is pressed.

Mh..what we are actually trying to achieve is to add buttons with two sections (or two buttons/rectangles if you will) to single cells. Buttons are to look like this [This is a button|...]. Users can execute a primary action with a click on the label "This is a button" or get to menu if pressing the "..." part with more options. The buttons are to be styled and do not use the whole cell. It would looks like this:

[text] [text] [This is a button|...]
[text] [text] [This is a button|...]
[text] [text] [ ]
[text] [text] [This is a button|...]
...

The content of the button actually depends on the information in row.

Because we are not dealing with a single button that spans the whole cell we need to check in which rectangle users clicked. But with the means we found this only works for the last button because the table uses only one painter instance.

[Updated on: Fri, 19 August 2016 16:37]

Report message to a moderator

Previous Topic:Vertical scrollbars broken on Mac OS (10.11)
Next Topic:Word wrapping problem in RichTextCellPainter
Goto Forum:
  


Current Time: Thu Sep 20 17:03:29 GMT 2018

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

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

Back to the top