Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-10-27 15:45:42 +0000
committerMarkus Keller2015-11-02 16:42:46 +0000
commitd166f958b55c0c62dde5c74dee5645ea913de43e (patch)
treee481e9524338b82735b3f39295467e1a5048ee2d
parent77e67a5a327fcbc21f924a968d1b7df66e79599d (diff)
downloadeclipse.platform.swt-d166f958b55c0c62dde5c74dee5645ea913de43e.tar.gz
eclipse.platform.swt-d166f958b55c0c62dde5c74dee5645ea913de43e.tar.xz
eclipse.platform.swt-d166f958b55c0c62dde5c74dee5645ea913de43e.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.java23
2 files changed, 22 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 49ae036a04..cf8ef849cd 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
@@ -1640,7 +1640,28 @@ 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) {
+ if (defaultButton != null && !defaultButton.isDisposed ()) {
+ defaultButton.setFocus ();
+ } else {
+ setFocus ();
+ }
+ }
}
@Override

Back to the top