|
Re: Keyboard accessibility on TableViewerColumn with a combo box [message #1277333 is a reply to message #1276658] |
Tue, 25 March 2014 21:34 |
Free Bird Messages: 2 Registered: March 2014 |
Junior Member |
|
|
I tried using the cellNAvigationStrategy but couldnt get the desired behaviour. I want to be bale to navigate to 2nd column using tab or arrow and activate the combobox and its cell editor.
Please guide what am i doing wrong in the code below ?
Thanks
{
//created table with SWT.FULL_SELECTION
Table table = new Table(contentArea, SWT.BORDER | SWT.FULL_SELECTION);
//create table viewer
viewer = new TableViewer(table);
viewer.setContentProvider(new IStructuredContentProvider());
//1st column
TableViewerColumn column1 = new TableViewerColumn(viewer, SWT.NONE);
column1 .getColumn().setText("Coulm 1");
viewer.getColumn().setWidth(200);
//2nd Column
TableViewerColumn column2 = new TableViewerColumn(viewer, SWT.NONE);
column2.getColumn().setText("Column 2");
column2.getColumn().setWidth(200);
CellNavigationStrategy strategy = new CellNavigationStrategy() {
@Override
public ViewerCell findSelectedCell(ColumnViewer viewer,
ViewerCell currentSelectedCell, Event event) {
ViewerCell cell = null;
switch (event.keyCode) {
case SWT.TAB:
if (event.stateMask == 0) {
cell = currentSelectedCell.getNeighbor(ViewerCell.RIGHT, true);
} else {
cell = currentSelectedCell.getNeighbor(ViewerCell.LEFT, true);
}
break;
}
if (cell != null) {
TableColumn t = runtimesTableViewer.getTable().getColumn(
cell.getColumnIndex());
runtimesTableViewer.getTable().showColumn(t);
}
return cell;
}
@Override
public boolean isNavigationEvent(ColumnViewer viewer, Event event) {
switch (event.keyCode) {
case SWT.TAB:
return true;
default:
return super.isNavigationEvent(viewer, event);
}
}
};
TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer,new FocusCellOwnerDrawHighlighter(runtimesTableViewer), strategy);
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(runtimesTableViewer) {
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION
|| (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.TAB)
|| event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
TableViewerEditor.create(viewer, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL
| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
| ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
runtimesTableViewer.getColumnViewerEditor().addEditorActivationListener(new ColumnViewerEditorActivationListener(){
@Override
public void afterEditorActivated(
ColumnViewerEditorActivationEvent event) {
}
@Override
public void afterEditorDeactivated(
ColumnViewerEditorDeactivationEvent event) {
}
@Override
public void beforeEditorActivated(
ColumnViewerEditorActivationEvent event) {
ViewerCell cell = (ViewerCell) event.getSource();
runtimesTableViewer.getTable().showColumn(viewer.getTable().getColumn(cell.getColumnIndex()));
}
@Override
public void beforeEditorDeactivated(
ColumnViewerEditorDeactivationEvent event) {
}
});
|
|
|
Powered by
FUDForum. Page generated in 0.03962 seconds