summaryrefslogtreecommitdiffstats
path: root/examples/org.eclipse.swt.snippets
diff options
context:
space:
mode:
authorGrant Gayed <grant_gayed@ca.ibm.com>2011-11-14 14:31:36 -0500
committerGrant Gayed <grant_gayed@ca.ibm.com>2011-11-14 14:31:36 -0500
commita9d842328be558230a1d5c559dbb997b71eda75e (patch)
treeba1491bc3ba2d26bae0cf96b7a26e50ff4641267 /examples/org.eclipse.swt.snippets
parent77b4d64997148208705632d7366ba42d974d02f1 (diff)
downloadeclipse.platform.swt-a9d842328be558230a1d5c559dbb997b71eda75e.tar.gz
eclipse.platform.swt-a9d842328be558230a1d5c559dbb997b71eda75e.tar.xz
eclipse.platform.swt-a9d842328be558230a1d5c559dbb997b71eda75e.zip
preserve column index when hiding/showing TableCursor
Diffstat (limited to 'examples/org.eclipse.swt.snippets')
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java17
1 files changed, 6 insertions, 11 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java
index 8e3ec0ba9a..ba85093a80 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java
@@ -11,7 +11,7 @@
package org.eclipse.swt.snippets;
/*
- * TableCursor example snippet: navigate a table cells with arrow keys.
+ * TableCursor example snippet: navigate a Table's cells with the arrow keys.
* Edit when user hits Return key. Exit edit mode by hitting Escape (cancels edit)
* or Return (applies edit to table).
*
@@ -143,20 +143,15 @@ public static void main(String[] args) {
// This signals the end of the multiple selection task.
table.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
- if (e.keyCode == SWT.CONTROL && (e.stateMask & SWT.SHIFT) != 0)
- return;
- if (e.keyCode == SWT.SHIFT && (e.stateMask & SWT.CONTROL) != 0)
- return;
- if (e.keyCode != SWT.CONTROL
- && (e.stateMask & SWT.CONTROL) != 0)
- return;
- if (e.keyCode != SWT.SHIFT && (e.stateMask & SWT.SHIFT) != 0)
- return;
+ if (e.keyCode == SWT.CONTROL && (e.stateMask & SWT.SHIFT) != 0) return;
+ if (e.keyCode == SWT.SHIFT && (e.stateMask & SWT.CONTROL) != 0) return;
+ if (e.keyCode != SWT.CONTROL && (e.stateMask & SWT.CONTROL) != 0) return;
+ if (e.keyCode != SWT.SHIFT && (e.stateMask & SWT.SHIFT) != 0) return;
TableItem[] selection = table.getSelection();
TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
table.showItem(row);
- cursor.setSelection(row, 0);
+ cursor.setSelection(row, cursor.getColumn());
cursor.setVisible(true);
cursor.setFocus();
}