Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/omni/OmniBoxControlContribution.java |
=================================================================== |
--- editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/omni/OmniBoxControlContribution.java (revision 2318) |
+++ editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/omni/OmniBoxControlContribution.java (working copy) |
@@ -138,7 +138,7 @@ |
} |
public void giveFocus() { |
- previousFocusControl = control.getDisplay().getFocusControl(); |
+ cacheFocusControl(control.getDisplay().getFocusControl()); |
control.setFocus(); |
clearWatermark(); |
} |
@@ -163,7 +163,7 @@ |
protected void handleMouseEnter() { |
inControl = true; |
//cache on mouse enter to ensure we can restore focus after an invocation initiated by a mouse click |
- previousFocusControl = Display.getDefault().getFocusControl(); |
+ cacheFocusControl(control.getDisplay().getFocusControl()); |
} |
protected void handleMouseExit() { |
@@ -180,6 +180,14 @@ |
} |
} |
+ private void cacheFocusControl(Control focusControl) { |
+ //since the point of caching the control is to restore focus away from us, |
+ //ignore any sets to "self" |
+ if (focusControl != control) { |
+ previousFocusControl = focusControl; |
+ } |
+ } |
+ |
private void clearWatermark() { |
//ensure watermark (or valid text) does not get re-cleared |
if (control.getForeground().equals(OmniBoxColors.SEARCHBOX_TEXT_COLOR)) { |
@@ -301,7 +309,6 @@ |
} |
} |
}); |
- |
} |
private void openPopup() { |