Fixed ESC not closing searchBar/goToDialog when they are visible but not focused

This commit is contained in:
bigguy345 committed 2025-12-20 11:59:34 +02:00
1 parent db0e7da834
commit a91039c026
3 files changed
+14 -19

No files matched your search

@@ -867,18 +867,12 @@ public class GuiScriptTextArea extends GuiNpcTextField {
KEYS_OVERLAY.keyTyped(c, i);
// Handle Go To Line dialog input first if it has focus
if (goToLineDialog.hasFocus()) {
if (goToLineDialog.keyTyped(c, i)) {
if (goToLineDialog.isVisible() &&goToLineDialog.keyTyped(c, i))
return true;
}
}
// Handle search bar input first if it has focus
if (searchBar.hasFocus()) {
if (searchBar.keyTyped(c, i)) {
return true;
}
}
if (searchBar.isVisible() && searchBar.keyTyped(c, i))
return true;
if (!active || KEYS_OVERLAY.showOverlay) return false;
@@ -296,18 +296,18 @@ public class GoToLineDialog {
}
public boolean keyTyped(char c, int keyCode) {
// Escape - close dialog
if (keyCode == Keyboard.KEY_ESCAPE && visible) {
close();
return true;
}
if (!visible || !focused)
return false;
boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
// Escape - close dialog
if (keyCode == Keyboard.KEY_ESCAPE) {
close();
return true;
}
// Enter - execute go to line
if (keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER) {
executeGoToLine();
@@ -805,6 +805,11 @@ public class SearchReplaceBar {
* @return true if input was consumed
*/
public boolean keyTyped(char c, int keyCode) {
if (keyCode == Keyboard.KEY_ESCAPE && visible) {
close();
return true;
}
if (!visible || (!searchFieldFocused && !replaceFieldFocused)) return false;
// Check modifier keys - don't let them trigger first-match issue
@@ -819,10 +824,6 @@ public class SearchReplaceBar {
return true; // Consume but don't process
}
if (keyCode == Keyboard.KEY_ESCAPE) {
close();
return true;
}
if (keyCode == Keyboard.KEY_TAB && showReplace) {
searchFieldFocused = !searchFieldFocused;