|
|
|
|
|
|
|
|
Re: CellEditor on DoubleCLick? [message #1691182 is a reply to message #1690717] |
Thu, 02 April 2015 22:14 |
Richard Dazzle Messages: 8 Registered: February 2015 |
Junior Member |
|
|
Still not managed to get it work.
Based on your comment "just add another set of bindings" this is my latest attempt.
// create grid layer composite
GridLayer grid = new GridLayer( viewport, colHeader, rowHeader, corner );
// configure NatTable with grid, theme, and labels
setLayer( grid );
addConfiguration( m_theme ); // just slightly modified modern theme
addConfiguration( m_labels ); // labels for style and enabling editing etc
addConfiguration( new XEditBindings() ); // *** try to have cell editor on double-click ***
configure();
Where XEditBindings is (based on DefaultEditBindings)
public class XEditBindings extends AbstractUiBindingConfiguration
{
@Override
public void configureUiBindings( UiBindingRegistry uiBindingRegistry )
{
// configure the space key to activate a cell editor via keyboard
// this is especially useful for changing the value for a checkbox
uiBindingRegistry.registerKeyBinding( new KeyEventMatcher( SWT.NONE, 32 ), new KeyEditAction() );
uiBindingRegistry.registerKeyBinding( new KeyEventMatcher( SWT.NONE, SWT.F2 ), new KeyEditAction() );
uiBindingRegistry.registerKeyBinding( new LetterOrDigitKeyEventMatcher(), new KeyEditAction() );
uiBindingRegistry.registerKeyBinding( new LetterOrDigitKeyEventMatcher( SWT.SHIFT ), new KeyEditAction() );
uiBindingRegistry.registerDoubleClickBinding( new CellEditorMouseEventMatcher( GridRegion.BODY ),
new MouseEditAction() );
uiBindingRegistry.registerSingleClickBinding( new CellEditorMouseEventMatcher( GridRegion.BODY ),
new SelectCellAction() );
uiBindingRegistry.registerMouseDragMode( new CellEditorMouseEventMatcher( GridRegion.BODY ),
new CellSelectionDragMode() );
uiBindingRegistry.registerFirstSingleClickBinding( new CellPainterMouseEventMatcher( GridRegion.BODY,
MouseEventMatcher.LEFT_BUTTON, CheckBoxPainter.class ), new SelectCellAction() );
uiBindingRegistry.registerFirstMouseDragMode( new CellPainterMouseEventMatcher( GridRegion.BODY,
MouseEventMatcher.LEFT_BUTTON, CheckBoxPainter.class ), new CellSelectionDragMode() );
}
}
Cells on single click get selected fine, then after about quarter-of-second the cell editor starts!
|
|
|
|
|
Re: CellEditor on DoubleCLick? [message #1691217 is a reply to message #1691193] |
Fri, 03 April 2015 14:00 |
Richard Dazzle Messages: 8 Registered: February 2015 |
Junior Member |
|
|
Excellent, many thanks Dirk - now all working correctly!
For others trying to do same thing he's my working code
// create grid layer composite
GridLayer grid = new GridLayer( viewport, colHeader, rowHeader, corner, false );
grid.addConfiguration( new XGridLayerConfiguration() );
// configure NatTable with grid, theme, and labels
setLayer( grid );
addConfiguration( m_theme ); // just slightly modified modern theme
addConfiguration( m_labels ); // labels for style and enabling editing etc
configure();
Andpublic class XGridLayerConfiguration extends AggregateConfiguration
{
public XGridLayerConfiguration()
{
// add default editing handler config
addConfiguration( new DefaultEditConfiguration() );
// instead of default editing UI config "DefaultEditBindings"
addConfiguration( new AbstractUiBindingConfiguration()
{
@Override
public void configureUiBindings( UiBindingRegistry uiBindingRegistry )
{
uiBindingRegistry.registerKeyBinding( new KeyEventMatcher( SWT.NONE, SWT.F2 ), new KeyEditAction() );
uiBindingRegistry.registerKeyBinding( new LetterOrDigitKeyEventMatcher(), new KeyEditAction() );
uiBindingRegistry.registerKeyBinding( new LetterOrDigitKeyEventMatcher( SWT.SHIFT ), new KeyEditAction() );
uiBindingRegistry.registerFirstDoubleClickBinding( new CellEditorMouseEventMatcher( GridRegion.BODY ),
new MouseEditAction() );
}
} );
// add default print UI bindings
addConfiguration( new DefaultPrintBindings() );
// add default excel export UI bindings
addConfiguration( new DefaultExportBindings() );
}
[Updated on: Fri, 03 April 2015 14:02] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04534 seconds