Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2018-06-19 11:01:27 +0000
committerXi Yan2018-06-26 13:51:48 +0000
commit3bf5e22438ca9d3c26eb07f25f363fdcf8344257 (patch)
tree003a780cbee9ab4545542ddd787f0e221d9be673 /tests/org.eclipse.swt.tests.gtk
parent913837c562a87a99024b3b1d5c815ed60dea5568 (diff)
downloadeclipse.platform.swt-3bf5e22438ca9d3c26eb07f25f363fdcf8344257.tar.gz
eclipse.platform.swt-3bf5e22438ca9d3c26eb07f25f363fdcf8344257.tar.xz
eclipse.platform.swt-3bf5e22438ca9d3c26eb07f25f363fdcf8344257.zip
Bug 302171 - Characters requiring <Alt Gr> cannot be generated using
Display.post(Event) 1) Added SWT.ALT_GR constant mapping to ISO_Level3_Shift (0xfe03). 2) Replaced OS.XTestFakeKeyEvent in Display.post, which only supported US keyboards, with gdk_test_simulate_key to simulate key event. Added the option to send key modifier together with key character in a single event to Display.post on GTK. Change-Id: I97311e639b612ac1f6aed23beb68034f40d211b1 Signed-off-by: Xi Yan <xixiyan@redhat.com>
Diffstat (limited to 'tests/org.eclipse.swt.tests.gtk')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302171_AltGr.java105
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302171_AltGr.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302171_AltGr.java
new file mode 100644
index 0000000000..503d14c469
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302171_AltGr.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug302171_AltGr {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ final Text text = new Text(shell, SWT.BORDER);
+ text.setSize(text.computeSize(150, SWT.DEFAULT));
+ shell.pack();
+ shell.open();
+
+ new Thread() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+
+ String string = "q23";
+
+ for (int i = 0; i < string.length(); i++) {
+ char ch = string.charAt(i);
+
+ /* Press the character */
+ Event event = new Event();
+ event.type = SWT.KeyDown;
+ event.character = ch;
+ display.post(event);
+
+ /* Release the character */
+ event.type = SWT.KeyUp;
+ display.post(event);
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+
+ /* Press SHIFT + ch */
+ event = new Event();
+ event.type = SWT.KeyDown;
+ event.character = ch;
+ event.stateMask = SWT.SHIFT;
+ display.post(event);
+
+ /* Release the character */
+ event.type = SWT.KeyUp;
+ display.post(event);
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+
+ /* Press ALT_GR + ch */
+ event = new Event();
+ event.type = SWT.KeyDown;
+ event.character = ch;
+ event.stateMask = SWT.ALT_GR;
+ display.post(event);
+
+ /* Release the character */
+ event.type = SWT.KeyUp;
+ display.post(event);
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+
+
+ }
+ }
+ }.start();
+
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+}

Back to the top