Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEric Williams2019-09-10 15:34:35 -0400
committerEric Williams2019-09-11 11:25:46 -0400
commit5562fddca07e3abaeec9be17c57902bc96842af2 (patch)
tree1245fc97cec76a7b03ade859ed18efce7c279d2c /tests
parentdf49aebd377808395623e6b00a09cf38c17a0354 (diff)
downloadeclipse.platform.swt-5562fddca07e3abaeec9be17c57902bc96842af2.tar.gz
eclipse.platform.swt-5562fddca07e3abaeec9be17c57902bc96842af2.tar.xz
eclipse.platform.swt-5562fddca07e3abaeec9be17c57902bc96842af2.zip
Bug 341117: ToolItem traversal does not fire deactivate event.
Send focus[In/Out] events in the parent ToolBar, in order to ensure traversal events get fired when traversing from a Control to an Item (like ToolItem). Otherwise Controls won't receive Deactivate events until the next Control has focus. Tested on GTK3.24 and X11, using the snippet attached. No AllNonBrowser JUnit tests fail. Change-Id: I899195aeef939f0b68fedb34a2f5a37d6e928409 Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug341117_ToolItemDeactivateNotSent.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug341117_ToolItemDeactivateNotSent.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug341117_ToolItemDeactivateNotSent.java
new file mode 100644
index 0000000000..9fff61298a
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug341117_ToolItemDeactivateNotSent.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat 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:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+
+
+public class Bug341117_ToolItemDeactivateNotSent {
+
+ public static void main(final String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ shell.setLayout(gridLayout);
+ shell.setSize(100, 140);
+ ToolBar toolBar = new ToolBar(shell, SWT.HORIZONTAL | SWT.FLAT);
+ toolBar.addListener(SWT.Deactivate, event -> System.out.println("Toolbar deactivated"));
+ toolBar.addListener(SWT.Activate, event -> System.out.println("Toolbar activated"));
+ ToolItem button = new ToolItem(toolBar, SWT.PUSH);
+ button.setText("A button");
+ addText("Text 1", shell);
+ addText("Text 2", shell);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+ private static void addText(final String textString, final Shell shell) {
+ Text text = new Text(shell, SWT.NONE);
+ text.setText(textString);
+ text.addListener(SWT.Deactivate, event -> System.out.println(textString + " deactivated"));
+ text.addListener(SWT.Activate, event -> System.out.println(textString + " activated"));
+ text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ }
+
+}

Back to the top