Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Unregister Keybindings
Unregister Keybindings [message #1004109] Tue, 22 January 2013 15:36 Go to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef WiszniewskyFriend
Messages: 11
Registered: January 2013
Junior Member
Hello,

I want to override some default selection behaviour: pressing the RETURN key while a single row is selected shifts the selection one row down. Instead of this I want to open an editor, showing all data concerning the selected row entry. So I started by unregistering the keybindings for the RETURN key.

First, in order to use my own keybinding implementation, I disabled the auto configuration of the nattable instance.


NatTable natTable = new NatTable(parent, NatTable.DEFAULT_STYLE_OPTIONS | SWT.BORDER,
                gridLayer,
                false);


Second I created my own MyNatTableSelectionBindings class, which is derived from DefaultSelectionBindings and which overrides the methods configureMoveDownBindings() and configureMoveUpBindings(). Therin I unregistered the keybindings for the RETURN key:

public class NatTableSelectionBindings extends DefaultSelectionBindings
{

protected void configureMoveUpBindings(UiBindingRegistry uiBindingRegistry, IKeyAction action) {
	super.configureMoveUpBindings(uiBindingRegistry, action);
	uiBindingRegistry.unregisterKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.CR));
	uiBindingRegistry.unregisterKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.CR));
}

protected void configureMoveDownBindings(UiBindingRegistry uiBindingRegistry, IKeyAction action) {
 // same as above
 ...
}

}


Finally I added the configuration to the nattable.

        natTable.addConfiguration(new MyNatTableSelectionBindings());
        natTable.configure();


Nevertheless when I select a row and press RETURN the default behaviour still applies and the row below gets selected.

Could you please help me to unregister this behaviour? Thanks in advance
Re: Unregister Keybindings [message #1004420 is a reply to message #1004109] Wed, 23 January 2013 07:43 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi,

I'm currently not able to debug into this. But this could have two reasons:

1. It is some time related issue. That means, when your configuration code for unregistering runs, the binding you want to unregister is not registered yet.
2. You are registering the key binding twice (one by the SelectionLayer configuration, one with your configuration on the NatTable), but you only remove it once.

Probably it is the second one. Nevertheless you should set your configuration to the SelectionLayer instead of the NatTable. Then it should work.

Greez,
Dirk
Re: Unregister Keybindings [message #1004482 is a reply to message #1004420] Wed, 23 January 2013 10:32 Go to previous messageGo to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef WiszniewskyFriend
Messages: 11
Registered: January 2013
Junior Member
Thanks for the quick answer.
Indeed I had to unregister the keybindings from both nattable and its selectionLayer.

Thanks a lot.
Re: Unregister Keybindings [message #1004519 is a reply to message #1004482] Wed, 23 January 2013 11:42 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Glad I could help. But still I suggest to only use a custom configuration for the SelectionLayer instead setting an additional one for the same purpose to the NatTable. Every action will otherwise be called twice which could have negative impact on your implementation.
Previous Topic:Update Java compiler settings
Next Topic:Row selection on cell click
Goto Forum:
  


Current Time: Tue Apr 23 14:59:47 GMT 2024

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

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

Back to the top