diff options
author | Silenio Quarti <silenio> | 2002-12-06 15:46:37 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2002-12-06 15:46:37 +0000 |
commit | aa4f474a7539ec7a83405545bd2e0e94ff16ca2a (patch) | |
tree | a4520291fcfae1018a4d097cb6594731b57bf761 | |
parent | 1bf326afbe4339c1a411790a574529e0e387220c (diff) | |
download | eclipse.platform.swt-aa4f474a7539ec7a83405545bd2e0e94ff16ca2a.tar.gz eclipse.platform.swt-aa4f474a7539ec7a83405545bd2e0e94ff16ca2a.tar.xz eclipse.platform.swt-aa4f474a7539ec7a83405545bd2e0e94ff16ca2a.zip |
*** empty log message ***
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java index c6a82a6ae9..4ddea6b600 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java @@ -201,6 +201,16 @@ Cursor findCursor () { return parent.findCursor (); } +void fixFocus () { + Shell shell = getShell (); + Control control = this; + while ((control = control.parent) != null) { + if (control.setFocus () || control == shell) return; + } + int window = OS.GetControlOwner (handle); + OS.ClearKeyboardFocus (window); +} + public boolean forceFocus () { checkWidget(); int window = OS.GetControlOwner (handle); @@ -482,6 +492,15 @@ public boolean isEnabled () { return OS.IsControlEnabled (topHandle ()); } +boolean isFocusAncestor () { + Display display = getDisplay (); + Control control = display.getFocusControl (); + while (control != null && control != this) { + control = control.parent; + } + return control == this; +} + public boolean isFocusControl () { checkWidget(); return hasFocus (); @@ -1090,8 +1109,37 @@ public void setVisible (boolean visible) { if ((state & HIDDEN) != 0) return; state |= HIDDEN; } + if (visible) { + /* + * It is possible (but unlikely), that application + * code could have disposed the widget in the show + * event. If this happens, just return. + */ + sendEvent (SWT.Show); + if (isDisposed ()) return; + } + + /* + * Feature in the Macintosh. If the receiver has focus, hiding + * the receiver causes no control to have focus. Also, the focus + * needs to be cleared from any TXNObject so that it stops blinking + * the caret. The fix is to assign focus to the first ancestor + * control that takes focus. If no control will take focus, clear + * the focus control. + */ + boolean fixFocus = false; + if (!visible) fixFocus = isFocusAncestor (); OS.HIViewSetVisible (topHandle (), visible); - sendEvent (visible ? SWT.Show : SWT.Hide); + if (!visible) { + /* + * It is possible (but unlikely), that application + * code could have disposed the widget in the show + * event. If this happens, just return. + */ + sendEvent (SWT.Hide); + if (isDisposed ()) return; + } + if (fixFocus) fixFocus (); } void setZOrder () { |