Unregister Keybindings [message #1004109] |
Tue, 22 January 2013 15:36 |
Franz-Josef Wiszniewsky 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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03342 seconds