Unregister Keybindings [message #1004109] |
Tue, 22 January 2013 10:36  |
Eclipse User |
|
|
|
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 #1004519 is a reply to message #1004482] |
Wed, 23 January 2013 06:42  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.07781 seconds