Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-07-02 16:49:51 +0000
committerArun Thondapu2015-10-23 18:17:17 +0000
commit39342ffc9e64b250c13f32265b898e0c6e960a40 (patch)
treec38dafacfee2737f8fe17a2c6335ec01df783e05
parentbec6bb11a053d17cfefea4cccfbf882fa9c023c9 (diff)
downloadeclipse.platform.swt-39342ffc9e64b250c13f32265b898e0c6e960a40.tar.gz
eclipse.platform.swt-39342ffc9e64b250c13f32265b898e0c6e960a40.tar.xz
eclipse.platform.swt-39342ffc9e64b250c13f32265b898e0c6e960a40.zip
Bug 471329: [GTK] Flipped button order and default button
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java21
2 files changed, 20 insertions, 11 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
index bf73f49cdf..328c55d5a1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
@@ -523,16 +523,6 @@ boolean restoreFocus () {
if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
boolean restored = savedFocus != null && savedFocus.setFocus ();
savedFocus = null;
- /*
- * This code is intentionally commented. When no widget
- * has been given focus, some platforms give focus to the
- * default button.
- */
-// if (restored) return true;
-// if (defaultButton != null && !defaultButton.isDisposed ()) {
-// if (defaultButton.setFocus ()) return true;
-// }
-// return false;
return restored;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index d65af5c328..45c58c4fed 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -1635,7 +1635,26 @@ public void open () {
Shell.class.cast(getParent()).open();
setVisible (true);
if (isDisposed ()) return;
- if (!restoreFocus () && !traverseGroup (true)) setFocus ();
+ /*
+ * When no widget has been given focus, or another push button has focus,
+ * give focus to the default button. This avoids overriding the default
+ * button.
+ */
+ boolean restored = restoreFocus ();
+ if (!restored) {
+ restored = traverseGroup (true);
+ }
+ if (restored) {
+ Control focusControl = display.getFocusControl ();
+ if (focusControl instanceof Button && (focusControl.style & SWT.PUSH) != 0) {
+ restored = false;
+ }
+ }
+ if (!restored && defaultButton != null && !defaultButton.isDisposed ()) {
+ defaultButton.setFocus ();
+ return;
+ }
+ setFocus ();
}
@Override

Back to the top