Fix search box interactions in the interface terminal.

This commit is contained in:
Sebastian Hartte
2020-08-24 22:33:04 +02:00
parent 2184d03d0b
commit aff94cec8c
@@ -90,7 +90,9 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
this.searchField.setMaxStringLength(25); this.searchField.setMaxStringLength(25);
this.searchField.setTextColor(0xFFFFFF); this.searchField.setTextColor(0xFFFFFF);
this.searchField.setVisible(true); this.searchField.setVisible(true);
this.searchField.setFocused2(true); this.searchField.setResponder(str -> this.refreshList());
this.addListener(this.searchField);
this.changeFocus(true);
} }
@Override @Override
@@ -131,11 +133,8 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
@Override @Override
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) { public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
if (this.searchField.mouseClicked(xCoord, yCoord, btn)) { if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) { this.searchField.setText("");
this.searchField.setText("");
this.refreshList();
}
return true; return true;
} }
@@ -173,11 +172,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
if (character == ' ' && this.searchField.getText().isEmpty()) { if (character == ' ' && this.searchField.getText().isEmpty()) {
return true; return true;
} }
if (this.searchField.charTyped(character, key)) { return super.charTyped(character, key);
this.refreshList();
return true;
}
return false;
} }
@Override @Override
@@ -245,7 +240,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
/** /**
* Rebuilds the list of interfaces. * Rebuilds the list of interfaces.
* * <p>
* Respects a search term if present (ignores case) and adding only matching * Respects a search term if present (ignores case) and adding only matching
* patterns. * patterns.
*/ */
@@ -338,12 +333,11 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
/** /**
* Tries to retrieve a cache for a with search term as keyword. * Tries to retrieve a cache for a with search term as keyword.
* * <p>
* If this cache should be empty, it will populate it with an earlier cache if * If this cache should be empty, it will populate it with an earlier cache if
* available or at least the cache for the empty string. * available or at least the cache for the empty string.
* *
* @param searchTerm the corresponding search * @param searchTerm the corresponding search
*
* @return a Set matching a superset of the search term * @return a Set matching a superset of the search term
*/ */
private Set<Object> getCacheForSearchTerm(final String searchTerm) { private Set<Object> getCacheForSearchTerm(final String searchTerm) {