Lines 77-82
Link Here
|
77 |
private final JMenu popupMenu; |
77 |
private final JMenu popupMenu; |
78 |
private final boolean asynchronous; |
78 |
private final boolean asynchronous; |
79 |
private boolean enabled = true; |
79 |
private boolean enabled = true; |
|
|
80 |
private boolean dismissOnFocusLost = true; |
80 |
private SearchTextField searchTextField; |
81 |
private SearchTextField searchTextField; |
81 |
private KeyAdapter quickSearchKeyAdapter; |
82 |
private KeyAdapter quickSearchKeyAdapter; |
82 |
private SearchFieldListener searchFieldListener; |
83 |
private SearchFieldListener searchFieldListener; |
Lines 231-236
Link Here
|
231 |
} |
232 |
} |
232 |
|
233 |
|
233 |
/** |
234 |
/** |
|
|
235 |
* Test whether the quick search field is automatically dismissed, |
236 |
* when it loses focus. This is <code>true</code> by default. |
237 |
* @return <code>true</code> when the search field is dismissed on focus lost, |
238 |
* <code>false</code> otherwise. |
239 |
* @since 7.48 |
240 |
*/ |
241 |
public boolean isDismissOnFocusLost() { |
242 |
return dismissOnFocusLost; |
243 |
} |
244 |
|
245 |
/** |
246 |
* Set whether the quick search field should be automatically dismissed, |
247 |
* when it loses focus. |
248 |
* @param dismissOnFocusLost <code>true</code> to automatically dismiss |
249 |
* the search field on focus lost, |
250 |
* <code>false</code> to ignore focus lost. |
251 |
* @since 7.48 |
252 |
*/ |
253 |
public void setDismissOnFocusLost(boolean dismissOnFocusLost) { |
254 |
this.dismissOnFocusLost = dismissOnFocusLost; |
255 |
} |
256 |
|
257 |
/** |
234 |
* Process this key event in addition to the key events obtained from the |
258 |
* Process this key event in addition to the key events obtained from the |
235 |
* component we're attached to. |
259 |
* component we're attached to. |
236 |
* @param ke a key event to process. |
260 |
* @param ke a key event to process. |
Lines 702-707
Link Here
|
702 |
|
726 |
|
703 |
@Override |
727 |
@Override |
704 |
public void focusGained(FocusEvent e) { |
728 |
public void focusGained(FocusEvent e) { |
|
|
729 |
if (!isDismissOnFocusLost()) { |
730 |
return ; |
731 |
} |
705 |
if (e.getSource() == searchTextField) { |
732 |
if (e.getSource() == searchTextField) { |
706 |
// make sure nothing is selected |
733 |
// make sure nothing is selected |
707 |
int n = searchTextField.getText().length(); |
734 |
int n = searchTextField.getText().length(); |
Lines 711-717
Link Here
|
711 |
|
738 |
|
712 |
@Override |
739 |
@Override |
713 |
public void focusLost(FocusEvent e) { |
740 |
public void focusLost(FocusEvent e) { |
714 |
if (e.isTemporary()) return ; |
741 |
if (e.isTemporary() || !isDismissOnFocusLost()) { |
|
|
742 |
return ; |
743 |
} |
715 |
Component oppositeComponent = e.getOppositeComponent(); |
744 |
Component oppositeComponent = e.getOppositeComponent(); |
716 |
if (e.getSource() != searchTextField) { |
745 |
if (e.getSource() != searchTextField) { |
717 |
((Component) e.getSource()).removeFocusListener(this); |
746 |
((Component) e.getSource()).removeFocusListener(this); |