Search code examples
eclipse-plugineclipse-rcpnattable

how to do mouse binding in hierarchical table


i want to register action on Mouse down for hierarchical table, even if i register it doesn't seems to be working it always taking the SelectCellAction on mouse down. i created Hierarchical table referring Hierarchicaltreelayerexpale from nattable examples.

the mouse binding i used

uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.rowHeaderLeftClick(SWT.NONE),
                                                          new action(selectionLayer));

could any please tell me y it is not working.


Solution

  • The HierarchicalTreeLayerExample you are referring to does not have a row header. Therefore a mouse binding for the row header will not have any effect.

    Instead you need to use a CellLabelMouseEventMatcher for the HierarchicalTreeLayer.LEVEL_HEADER_CELL like this:

    uiBindingRegistry.registerFirstMouseDownBinding(
            new CellLabelMouseEventMatcher(
                    GridRegion.BODY, 
                    MouseEventMatcher.LEFT_BUTTON, 
                    HierarchicalTreeLayer.LEVEL_HEADER_CELL),
            new NoOpMouseAction());
    

    Note that the selection handling is configured in the SelectionLayer and the SelectCellAction is registered on mouse down. So registering on single click will also not work, as the selection is triggered before.