Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » RMB on a cell returning last selected cell position as null
RMB on a cell returning last selected cell position as null [message #1398161] Thu, 10 July 2014 18:16 Go to next message
Sunny          is currently offline Sunny Friend
Messages: 37
Registered: September 2011
Member
Hi Dirk,
To enable RMB on my nattable I added a uibinding like this:

uiBindingRegistry.registerMouseDownBinding( new MouseEventMatcher( SWT.NONE, GridRegion.BODY,
MouseEventMatcher.RIGHT_BUTTON ), new IMouseAction()
{

@Override
public void run( NatTable natTable, MouseEvent event )
{
int colPosition = LayerUtil.convertColumnPosition( natTable,
natTable.getColumnPositionByX( event.x ), selectionLayer );
int rowPosition = LayerUtil.convertRowPosition( natTable,
natTable.getRowPositionByY( event.y ), selectionLayer );



if( !selectionLayer.isCellPositionSelected( colPosition, rowPosition ) )
{
selectCellAction.run( natTable, event );
}


}

} );

But I found that sometimes the getLastSelectedCellPosition() on selectionLayer returns me null, which is causing some problems in my application.

Is that a correct way to implement RMB binding?

Thanks.
Re: RMB on a cell returning last selected cell position as null [message #1398236 is a reply to message #1398161] Thu, 10 July 2014 20:45 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
It looks correct.

What do you need the getLastSelectedCellPosition() for? As far as I remember that method is mainly used internally for selection movement and selection anchor handling.

Also I suggest do execute commands rather than calling run() on another action, as the run() method will again perform the transformation code to determine the coordinates.
Re: RMB on a cell returning last selected cell position as null [message #1398666 is a reply to message #1398236] Fri, 11 July 2014 11:59 Go to previous messageGo to next message
Sunny          is currently offline Sunny Friend
Messages: 37
Registered: September 2011
Member
If my table implements ISelectionProvider ( org.eclipse.jface.viewers.ISelectionProvider ) for I need to provide some selection through overridden getSelection().
I didn't see another way of providing selection other than selection layer's getLastSelectedCellPosition(). Is there a better way of getting selection from selection Layer , I mean is there another API to get selection?
Re: RMB on a cell returning last selected cell position as null [message #1398671 is a reply to message #1398666] Fri, 11 July 2014 12:07 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
For such cases NatTable ships with the RowSelectionProvider.

Check the _5054_SelectionProviderExample under Tutorial Example - Layers - Selection -SelectionProviderExample
Re: RMB on a cell returning last selected cell position as null [message #1398723 is a reply to message #1398671] Fri, 11 July 2014 13:38 Go to previous message
Sunny          is currently offline Sunny Friend
Messages: 37
Registered: September 2011
Member
Thanks. I will try this.
Previous Topic:Sorting and Indices
Next Topic:nattable drop bug with scrollbar
Goto Forum:
  


Current Time: Thu Apr 18 15:35:07 GMT 2024

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

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

Back to the top