|
Re: Customizing Traverse-keys for ColumnViewerEditor [message #510679 is a reply to message #508892] |
Thu, 28 January 2010 10:31 |
Arne Jans Messages: 9 Registered: December 2009 |
Junior Member |
|
|
Hello,
I am the author of the original post. I have solved this problem with the snippet Snippet059CellNavigationIn33. Using the internal API with reflection did the trick. But as the snippet-comment says: "This snippet uses internal API by reflection so its not guaranteed to work for ever", so handle with care and better dont forget about it.
To enable InEdit-Cursorcellnavigation, I had to enhance the if-expressions in the method TableViewerEditor.processTraverseEvent as follows:
protected void processTraverseEvent(int columnIndex, ViewerRow row,
TraverseEvent event) {
ViewerCell cell2edit = null;
if ((event.detail == SWT.TRAVERSE_TAB_PREVIOUS)||
((event.detail == SWT.TRAVERSE_ARROW_PREVIOUS) &&
((ColumnViewerEditorActivationStrategyWithMemory)editorActivationStrategy).getLastColumnViewerEditorActivationEvent().keyCode != SWT.F2)) {
event.doit = false;
if ((((event.stateMask & SWT.CTRL) == SWT.CTRL) || (event.keyCode == SWT.ARROW_UP))
&& (feature & TABBING_VERTICAL) == TABBING_VERTICAL) {
cell2edit = searchCellAboveBelow(row, getViewer(), columnIndex, true);
} else if ((feature & TABBING_HORIZONTAL) == TABBING_HORIZONTAL) {
cell2edit = searchPreviousCell(row, row.getCell(columnIndex),
row.getCell(columnIndex), getViewer());
}
} else if ((event.detail == SWT.TRAVERSE_TAB_NEXT)||
((event.detail == SWT.TRAVERSE_ARROW_NEXT) &&
((ColumnViewerEditorActivationStrategyWithMemory)editorActivationStrategy).getLastColumnViewerEditorActivationEvent().keyCode != SWT.F2)) {
event.doit = false;
if ((((event.stateMask & SWT.CTRL) == SWT.CTRL)||(event.keyCode == SWT.ARROW_DOWN))
&& (feature & TABBING_VERTICAL) == TABBING_VERTICAL) {
cell2edit = searchCellAboveBelow(row, getViewer(), columnIndex,
false);
} else if ((feature & TABBING_HORIZONTAL) == TABBING_HORIZONTAL) {
cell2edit = searchNextCell(row, row.getCell(columnIndex), row
.getCell(columnIndex), getViewer());
}
}
...
If you wonder about the fragment: Quote: | ((ColumnViewerEditorActivationStrategyWithMemory)editorActiv ationStrategy).getLastColumnViewerEditorActivationEvent().ke yCode != SWT.F2))
|
I did this to let the user decide, if he wants InEdit-cursornavigation between cells. He can press F2 to edit a cell, and the feature is temporarily disabled, just like in MS Excel. This is so that you can navigate the cellcontent as usual to fix typos etc. I had to derive the subclass ColumnViewerEditorActivationStrategyWithMemory from ColumnViewerEditorActivationStrategy and add the method getLastColumnViewerEditorActivationEvent that simply delivers the last EditorActivationEvent that was remembered as a local field in ColumnViewerEditorActivationStrategyWithMemory.
Hope this helps somebody who has similar problems.
Regards,
Arne Jans
[Updated on: Thu, 28 January 2010 10:32] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02377 seconds