File tree Expand file tree Collapse file tree 2 files changed +7
-18
lines changed
app/src/cc/arduino/contributions/ui Expand file tree Collapse file tree 2 files changed +7
-18
lines changed Original file line number Diff line number Diff line change 3333import javax .swing .event .DocumentEvent ;
3434import javax .swing .event .DocumentListener ;
3535import java .awt .*;
36+ import java .awt .event .ActionEvent ;
37+ import java .awt .event .ActionListener ;
3638import java .awt .event .FocusEvent ;
3739import java .awt .event .FocusListener ;
3840
@@ -66,35 +68,21 @@ public void focusGained(FocusEvent focusEvent) {
6668 }
6769 });
6870
69- getDocument ().addDocumentListener (new DocumentListener () {
70- public void removeUpdate (DocumentEvent e ) {
71- applyFilter ();
72- }
73-
74- public void insertUpdate (DocumentEvent e ) {
75- applyFilter ();
76- }
77-
78- public void changedUpdate (DocumentEvent e ) {
71+ addActionListener (new ActionListener () {
72+ @ Override
73+ public void actionPerformed (ActionEvent e ) {
7974 applyFilter ();
8075 }
8176 });
8277 }
8378
84- private String lastFilter = "" ;
85-
86- private void applyFilter () {
79+ public void applyFilter () {
8780 String filter = showingHint ? "" : getText ();
8881 filter = filter .toLowerCase ();
8982
9083 // Replace anything but 0-9, a-z, or : with a space
9184 filter = filter .replaceAll ("[^\\ x30-\\ x39^\\ x61-\\ x7a^\\ x3a]" , " " );
9285
93- // Fire event only if the filter is changed
94- if (filter .equals (lastFilter ))
95- return ;
96-
97- lastFilter = filter ;
9886 onFilter (filter .split (" " ));
9987 }
10088
Original file line number Diff line number Diff line change @@ -320,6 +320,7 @@ public void setFilterText(String filterText) {
320320 listener .focusGained (new FocusEvent (filterField , FocusEvent .FOCUS_GAINED ));
321321 }
322322 filterField .setText (filterText );
323+ filterField .applyFilter ();
323324 }
324325
325326 public void selectDropdownItemByClassName (String dropdownItem ) {
You can’t perform that action at this time.
0 commit comments