Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Mouse Event for certain Layer
Mouse Event for certain Layer [message #1400694] Mon, 14 July 2014 15:36 Go to next message
Alexander Klatt is currently offline Alexander KlattFriend
Messages: 56
Registered: April 2014
Member
Hello,
I would like to add a MouseListener to one of the table's layers. How is the usual approach to this?
Unfortunately I did not find any matching example in the example program.
Re: Mouse Event for certain Layer [message #1400779 is a reply to message #1400694] Mon, 14 July 2014 17:58 Go to previous messageGo to next message
Dirk Fauth is currently online Dirk FauthFriend
Messages: 1653
Registered: July 2012
Senior Member
There is no example on how to register a MouseListener to a certain layer, because that is not possible.

In NatTable you are registering a MouseAction for a MouseEvent to the UIBindingRegistry. Typically the action is triggering a command that is transported down the layer stack and register the corresponding command handler to the layer you want.

On our website you find some basic information about the command & event pattern in NatTable. There you find also some german articles about NatTable.

https://www.eclipse.org/nattable/documentation.php?page=articles

If you don't understand German, at least the examples might be helpful.
Re: Mouse Event for certain Layer [message #1401287 is a reply to message #1400779] Tue, 15 July 2014 11:54 Go to previous messageGo to next message
Alexander Klatt is currently offline Alexander KlattFriend
Messages: 56
Registered: April 2014
Member
Okay thanks! So if I take this for example:

        natTable.getUiBindingRegistry().registerMouseDownBinding(new MouseEventMatcher(GridRegion.CORNER), new IMouseAction() {
            @Override
            public void run(NatTable natTable, MouseEvent event) {
                System.out.println("Hello from the corner.");
            }
        });


This seems to work fine. Though in this article (German) it is mentioned that the action will be "overwritten". Does this mean that other MouseActions for the corner region will not be performed anymore?
Re: Mouse Event for certain Layer [message #1401329 is a reply to message #1401287] Tue, 15 July 2014 12:59 Go to previous messageGo to next message
Dirk Fauth is currently online Dirk FauthFriend
Messages: 1653
Registered: July 2012
Senior Member
Yes, it is not possible to register several actions for the same mouse event (e.g. left click on the column header). Only the first action that is found in the registry for an event will be executed.
Re: Mouse Event for certain Layer [message #1401385 is a reply to message #1401329] Tue, 15 July 2014 14:23 Go to previous messageGo to next message
Alexander Klatt is currently offline Alexander KlattFriend
Messages: 56
Registered: April 2014
Member
Okay, so do you always check if there is already anything registered (i.e. by Default elements) before you register your own action?

For example, I would like to implement a single click binding on the column header. Do I first have to unregister the column selection binding which also listens to the single click event?
Re: Mouse Event for certain Layer [message #1401390 is a reply to message #1401385] Tue, 15 July 2014 14:31 Go to previous messageGo to next message
Dirk Fauth is currently online Dirk FauthFriend
Messages: 1653
Registered: July 2012
Senior Member
there is always a registerFirstXxx method available that puts the action on top.
Re: Mouse Event for certain Layer [message #1401393 is a reply to message #1401390] Tue, 15 July 2014 14:35 Go to previous message
Dirk Fauth is currently online Dirk FauthFriend
Messages: 1653
Registered: July 2012
Senior Member
The SingleClickSortConfiguration for example registers a SortAction on single click wich overrides the selection behavior registered by the SelectionLayer.
Previous Topic:nattable drop bug with scrollbar
Next Topic:Best way to apply dynamic styling in 1.1
Goto Forum:
  


Current Time: Tue May 26 06:00:56 GMT 2015

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

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