diff --git a/openide.awt/apichanges.xml b/openide.awt/apichanges.xml --- a/openide.awt/apichanges.xml +++ b/openide.awt/apichanges.xml @@ -50,6 +50,20 @@ AWT API + + + QuickSearch allows to customize of whether the quick search field should dismiss on focus lost, or not. + + + + + + QuickSearch.isDismissOnFocusLost() and QuickSearch.setDismissOnFocusLost(boolean) methods are added. + They can be used to change the default behavior of automatic dismiss of the quick search field on focus lost. + + + + Support for Check for Updates feature diff --git a/openide.awt/manifest.mf b/openide.awt/manifest.mf --- a/openide.awt/manifest.mf +++ b/openide.awt/manifest.mf @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.awt OpenIDE-Module-Localizing-Bundle: org/openide/awt/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 7.47 +OpenIDE-Module-Specification-Version: 7.48 diff --git a/openide.awt/src/org/openide/awt/QuickSearch.java b/openide.awt/src/org/openide/awt/QuickSearch.java --- a/openide.awt/src/org/openide/awt/QuickSearch.java +++ b/openide.awt/src/org/openide/awt/QuickSearch.java @@ -77,6 +77,7 @@ private final JMenu popupMenu; private final boolean asynchronous; private boolean enabled = true; + private boolean dismissOnFocusLost = true; private SearchTextField searchTextField; private KeyAdapter quickSearchKeyAdapter; private SearchFieldListener searchFieldListener; @@ -231,6 +232,29 @@ } /** + * Test whether the quick search field is automatically dismissed, + * when it loses focus. This is true by default. + * @return true when the search field is dismissed on focus lost, + * false otherwise. + * @since 7.48 + */ + public boolean isDismissOnFocusLost() { + return dismissOnFocusLost; + } + + /** + * Set whether the quick search field should be automatically dismissed, + * when it loses focus. + * @param dismissOnFocusLost true to automatically dismiss + * the search field on focus lost, + * false to ignore focus lost. + * @since 7.48 + */ + public void setDismissOnFocusLost(boolean dismissOnFocusLost) { + this.dismissOnFocusLost = dismissOnFocusLost; + } + + /** * Process this key event in addition to the key events obtained from the * component we're attached to. * @param ke a key event to process. @@ -702,6 +726,9 @@ @Override public void focusGained(FocusEvent e) { + if (!isDismissOnFocusLost()) { + return ; + } if (e.getSource() == searchTextField) { // make sure nothing is selected int n = searchTextField.getText().length(); @@ -711,7 +738,9 @@ @Override public void focusLost(FocusEvent e) { - if (e.isTemporary()) return ; + if (e.isTemporary() || !isDismissOnFocusLost()) { + return ; + } Component oppositeComponent = e.getOppositeComponent(); if (e.getSource() != searchTextField) { ((Component) e.getSource()).removeFocusListener(this);