diff options
author | Markus Keller | 2015-07-02 16:49:51 +0000 |
---|---|---|
committer | Arun Thondapu | 2015-10-23 18:17:17 +0000 |
commit | 39342ffc9e64b250c13f32265b898e0c6e960a40 (patch) | |
tree | c38dafacfee2737f8fe17a2c6335ec01df783e05 | |
parent | bec6bb11a053d17cfefea4cccfbf882fa9c023c9 (diff) | |
download | eclipse.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
Change-Id: I69c36244379974c84955ec201376d68d11f7ff7a
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java | 10 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java | 21 |
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 |