Skip to main content



      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 08:43 Go to next message
Eclipse UserFriend
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 15:14 Go to previous messageGo to next message
Eclipse UserFriend
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 04:55 Go to previous message
Eclipse UserFriend
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 May 20 02:37:20 EDT 2025

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

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

Back to the top