Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java12
-rw-r--r--tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug565089_TableCtrlA.java67
2 files changed, 69 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index 3a7e079c4c..d48bd58564 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -3751,16 +3751,6 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, long wParam, long lPa
}
/*
- * Force the table to have focus so that when the user
- * reselects the focus item, the LVIS_FOCUSED state bits
- * for the item will be set. If the user did not click on
- * an item, then set focus to the table so that it will
- * come to the front and take focus in the work around
- * below.
- */
- OS.SetFocus (handle);
-
- /*
* Feature in Windows. When the user selects outside of
* a table item, Windows deselects all the items, even
* when the table is multi-select. While not strictly
@@ -3772,6 +3762,8 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, long wParam, long lPa
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
+ /* We're skipping default processing, but at least set focus to control */
+ OS.SetFocus (handle);
return LRESULT.ZERO;
}
}
diff --git a/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug565089_TableCtrlA.java b/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug565089_TableCtrlA.java
new file mode 100644
index 0000000000..de3d446f73
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug565089_TableCtrlA.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Syntevo and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Syntevo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.win32.snippets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug565089_TableCtrlA {
+ public static int counter = 0;
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout(SWT.VERTICAL));
+
+ final Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
+ table.setHeaderVisible(true);
+ final TableColumn column = new TableColumn(table, SWT.LEFT);
+ column.setText("Column");
+ column.setWidth(200);
+
+ for (int i = 0; i < 3; i++) {
+ final TableItem item = new TableItem(table, 0);
+ item.setText(String.valueOf(i + 1));
+ }
+
+ table.select(0);
+
+ final Text text = new Text(shell, SWT.MULTI | SWT.BORDER);
+ text.setText("- select the table row 3\n"
+ + "- click into this field\n"
+ + "- quickly click at table row 3 again and press Ctrl+A\n\n"
+ + "=> for a short time all rows look selected, but then row 3 gets selected again");
+
+ table.addListener(SWT.KeyDown, event -> {
+ if (event.keyCode == 'a' && (event.stateMask & SWT.MODIFIER_MASK) == SWT.MOD1) {
+ System.out.println("Select all");
+ counter = 0;
+ table.selectAll();
+ }
+ });
+
+ shell.setSize(400, 300);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+}

Back to the top