mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 03:25:02 +00:00
Improved interaction between SearchReplaceBar and GoToLineDialog
This commit is contained in:
1 parent
762d52f658
commit
d06e7df1a0
2 files changed
+23
-9
No files matched your search
@@ -822,28 +822,40 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
});
|
||||
|
||||
// SEARCH: Open search bar (Ctrl+R)
|
||||
// Works in search bar.
|
||||
KEYS.SEARCH.setTask(e -> {
|
||||
if (!e.isPress() || !isActive.get())
|
||||
if (!e.isPress() || !isActive.get() && !searchBar.isVisible())
|
||||
return;
|
||||
|
||||
unfocusAll();
|
||||
searchBar.openSearch();
|
||||
});
|
||||
|
||||
// SEARCH_REPLACE: Open search+replace bar (Ctrl+Shift+R)
|
||||
// Works in search bar.
|
||||
KEYS.SEARCH_REPLACE.setTask(e -> {
|
||||
if (!e.isPress() || !isActive.get())
|
||||
if (!e.isPress() || !isActive.get() && !searchBar.isVisible())
|
||||
return;
|
||||
|
||||
unfocusAll();
|
||||
searchBar.openSearchReplace();
|
||||
});
|
||||
|
||||
// GO_TO_LINE: Open go to line dialog (Ctrl+G)
|
||||
// Works in search bar.
|
||||
KEYS.GO_TO_LINE.setTask(e -> {
|
||||
if (!e.isPress() || !isActive.get())
|
||||
if (!e.isPress() || !isActive.get() && !searchBar.isVisible())
|
||||
return;
|
||||
|
||||
|
||||
unfocusAll();
|
||||
goToLineDialog.toggle();
|
||||
});
|
||||
}
|
||||
|
||||
public void unfocusAll() {
|
||||
if (searchBar.hasFocus()) searchBar.unfocus();
|
||||
if (goToLineDialog.hasFocus()) goToLineDialog.unfocus();
|
||||
}
|
||||
// ==================== KEYBOARD INPUT HANDLING ====================
|
||||
|
||||
/**
|
||||
@@ -1726,9 +1738,8 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
public void updateCursorCounter() {
|
||||
// Only process KeyPresets if search bar and go-to-line dialog don't have focus
|
||||
// This prevents COPY, PASTE, UNDO, etc. from firing when typing in dialogs
|
||||
if (!searchBar.hasFocus() && !goToLineDialog.hasFocus()) {
|
||||
KEYS.tick();
|
||||
}
|
||||
KEYS.tick();
|
||||
|
||||
searchBar.updateCursor();
|
||||
goToLineDialog.updateCursor();
|
||||
++this.cursorCounter;
|
||||
|
||||
@@ -118,7 +118,7 @@ public class GoToLineDialog {
|
||||
}
|
||||
|
||||
public void toggle() {
|
||||
if (visible) {
|
||||
if (visible && focused) {
|
||||
close();
|
||||
} else {
|
||||
show();
|
||||
@@ -129,6 +129,9 @@ public class GoToLineDialog {
|
||||
return visible && focused;
|
||||
}
|
||||
|
||||
public void unfocus() {
|
||||
focused = false;
|
||||
}
|
||||
// ==================== RENDERING ====================
|
||||
|
||||
public void draw(int mouseX, int mouseY) {
|
||||
@@ -164,7 +167,7 @@ public class GoToLineDialog {
|
||||
int fieldY = y + padding + 14 + 5;
|
||||
textFieldWidth = dialogWidth - padding * 2;
|
||||
drawTextField(fieldX, fieldY, textFieldWidth, textFieldHeight, inputText, cursor,
|
||||
selectionStart, selectionEnd, scrollOffset, true);
|
||||
selectionStart, selectionEnd, scrollOffset, focused);
|
||||
|
||||
if (inputText.isEmpty())
|
||||
font.drawString("[Line][:Column]", x + padding + 6, y + padding + 23, 0xFF888888);
|
||||
|
||||
Reference in new issue
Block a user