Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to correctly register an Action on the GridRegion.Body Mouse.RMB
How to correctly register an Action on the GridRegion.Body Mouse.RMB [message #1811248] Thu, 29 August 2019 12:43 Go to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
Hello,

i'm trying to react on user interaction on the GridRegion.Body

when the user clicks RIGHT_BUTTON, an Action/Command shall be executed, as this populates information needed in the popup menu.

i tried registering the PopupMenuAction like this:

uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(
				SWT.NONE, GridRegion.BODY, MouseEventMatcher.RIGHT_BUTTON),
				new SelectPopupMenuAction(natTableWrapper, bodyHeaderMenu, selectionLayer));


Note that
class SelectPopupMenuAction extends AbstractMouseSelectionAction

it selects the row (if the Mouse was above an Row) executes some more code then opens the PopupMenu.
this is all working, but it only pops up, if the Mouse was above an area where Items are listed.
I need this Action to be triggered when no Item is below too!
As if no Item is below i need to clear a property in my Application.
Re: How to correctly register an Action on the GridRegion.Body Mouse.RMB [message #1811264 is a reply to message #1811248] Thu, 29 August 2019 19:14 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
The default MouseEventMatcher implementation is only working if regionLabels are available. But a LabelStack is only available on cells. So if you click in a region without cells, the MouseEventMatcher will never match.

Therefore you need to implement a custom IMouseEventMatcher that can handle this scenario. But remember that you will get a -1 for the row position that needs to be handled.

new IMouseEventMatcher() {
    @Override
    public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
        boolean eventRegionMatches = ((natTable != null && regionLabels == null)
                || regionLabels != null && regionLabels.hasLabel(GridRegion.BODY));

        boolean buttonMatches = event.button == MouseEventMatcher.RIGHT_BUTTON;

        return eventRegionMatches && buttonMatches;
    }

}
Re: How to correctly register an Action on the GridRegion.Body Mouse.RMB [message #1811297 is a reply to message #1811264] Fri, 30 August 2019 08:55 Go to previous message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
thanks for your fast reply, thats exactly what i was looking for!
Previous Topic:Wrong order after inserting a row into a NatTable
Next Topic:Custom Scrollbar Mousewheel Support
Goto Forum:
  


Current Time: Tue Jun 22 13:55:15 GMT 2021

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

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

Back to the top