fix: not being able to type E in grid search box

Fixes #3537
This commit is contained in:
raoulvdberge
2023-07-07 21:06:14 +02:00
parent 34d9e6865c
commit 32f4f0bce3
5 changed files with 13 additions and 20 deletions

View File

@@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
### Fixed
- Fixed not being able to type "e" in Grid search box.
## [1.12.2] - 2023-07-05 ## [1.12.2] - 2023-07-05
### Fixed ### Fixed

View File

@@ -81,7 +81,7 @@ public class DetectorScreen extends BaseScreen<DetectorContainerMenu> {
return true; return true;
} }
if (amountField.keyPressed(key, scanCode, modifiers)) { if (amountField.keyPressed(key, scanCode, modifiers) || amountField.canConsumeInput()) {
return true; return true;
} }

View File

@@ -101,7 +101,7 @@ public class FilterScreen extends BaseScreen<FilterContainerMenu> {
return true; return true;
} }
if (nameField.keyPressed(key, scanCode, modifiers)) { if (nameField.keyPressed(key, scanCode, modifiers) || nameField.canConsumeInput()) {
return true; return true;
} }

View File

@@ -686,7 +686,6 @@ public class GridScreen extends BaseScreen<GridContainerMenu> implements IScreen
if (searchField.keyPressed(key, scanCode, modifiers)) { if (searchField.keyPressed(key, scanCode, modifiers)) {
return true; return true;
} }
return super.keyPressed(key, scanCode, modifiers); return super.keyPressed(key, scanCode, modifiers);
} }

View File

@@ -65,57 +65,47 @@ public class SearchWidget extends EditBox {
@Override @Override
public boolean keyPressed(int keyCode, int scanCode, int modifier) { public boolean keyPressed(int keyCode, int scanCode, int modifier) {
boolean result = super.keyPressed(keyCode, scanCode, modifier); if (super.keyPressed(keyCode, scanCode, modifier)) {
return true;
}
if (isFocused()) { if (isFocused()) {
if (keyCode == GLFW.GLFW_KEY_UP) { if (keyCode == GLFW.GLFW_KEY_UP) {
updateHistory(-1); updateHistory(-1);
result = true;
} else if (keyCode == GLFW.GLFW_KEY_DOWN) { } else if (keyCode == GLFW.GLFW_KEY_DOWN) {
updateHistory(1); updateHistory(1);
result = true;
} else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) { } else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) {
saveHistory(); saveHistory();
if (canLoseFocus) { if (canLoseFocus) {
setFocused(false); setFocused(false);
} }
result = true;
} else if (keyCode == GLFW.GLFW_KEY_ESCAPE) { } else if (keyCode == GLFW.GLFW_KEY_ESCAPE) {
saveHistory(); saveHistory();
if (!canLoseFocus) { if (!canLoseFocus) {
// If we can't lose focus, // If we can't lose focus,
// and we press escape, // and we press escape,
// we unfocus ourselves, // we unfocus ourselves,
// and close the screen immediately. // and close the screen immediately.
setFocused(false); setFocused(false);
return false; // Bubble the event up to the screen.
result = false; // Bubble the event up to the screen.
} else { } else {
// If we can lose focus, // If we can lose focus,
// and we press escape, // and we press escape,
// we unfocus ourselves. // we unfocus ourselves.
// On the next escape press, the screen will close. // On the next escape press, the screen will close.
setFocused(false); setFocused(false);
return true; // Swallow
result = true;
} }
} }
} }
if (BaseScreen.isKeyDown(RSKeyBindings.FOCUS_SEARCH_BAR) && canLoseFocus) { if (BaseScreen.isKeyDown(RSKeyBindings.FOCUS_SEARCH_BAR) && canLoseFocus) {
setFocused(!isFocused()); setFocused(!isFocused());
saveHistory(); saveHistory();
return true;
result = true;
} }
return result; return isFocused() && canConsumeInput() && keyCode != GLFW.GLFW_KEY_ESCAPE;
} }
private void updateHistory(int delta) { private void updateHistory(int delta) {