mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 01:05:12 +00:00
Implemented main editor focus/unfocus callbacks to GoToLine/SearchReplaceBar
This commit is contained in:
1 parent
825f3b4a39
commit
7ec0ce6f94
3 files changed
+22
-1
No files matched your search
@@ -133,6 +133,18 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
int maxScroll = Math.max(0, container.linesCount - visible);
|
||||
scroll.scrollToLine(lineIdx, visible, maxScroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unfocusMainEditor() {
|
||||
// Save position but unfocus
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusMainEditor() {
|
||||
active = true;
|
||||
selection.markActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialogClose() {
|
||||
|
||||
@@ -66,6 +66,10 @@ public class GoToLineDialog {
|
||||
|
||||
/** Called when dialog closes - should restore focus to editor */
|
||||
void onDialogClose();
|
||||
|
||||
void unfocusMainEditor();
|
||||
|
||||
void focusMainEditor();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,6 +105,7 @@ public class GoToLineDialog {
|
||||
selectionEnd = 0;
|
||||
scrollOffset = 0;
|
||||
markActivity();
|
||||
if (callback != null) callback.unfocusMainEditor();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
@@ -108,6 +113,7 @@ public class GoToLineDialog {
|
||||
focused = false;
|
||||
if (callback != null) {
|
||||
callback.onDialogClose();
|
||||
callback.focusMainEditor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,6 +261,7 @@ public class GoToLineDialog {
|
||||
if (mouseX >= fieldX && mouseX < fieldX + textFieldWidth &&
|
||||
mouseY >= fieldY && mouseY < fieldY + textFieldHeight) {
|
||||
focused = true;
|
||||
if (callback != null) callback.unfocusMainEditor();
|
||||
// Position cursor based on click
|
||||
int clickX = mouseX - fieldX - 4;
|
||||
String visibleText = scrollOffset > 0 && scrollOffset < inputText.length()
|
||||
|
||||
@@ -524,7 +524,9 @@ public class SearchReplaceBar {
|
||||
long now = System.currentTimeMillis();
|
||||
boolean isSearchFieldClick = isMouseOver(mouseX, mouseY, currentX, rowY - 2, textFieldWidth, textFieldHeight + 4);
|
||||
boolean isReplaceFieldClick = showReplace && isMouseOver(mouseX, mouseY, x + padding, y + barHeight, textFieldWidth, textFieldHeight + 4);
|
||||
|
||||
|
||||
if ((isSearchFieldClick || isReplaceFieldClick) && callback != null) callback.unfocusMainEditor();
|
||||
|
||||
if (isSearchFieldClick) {
|
||||
boolean sameField = lastClickWasSearch;
|
||||
if (sameField && now - lastClickTime < 300) {
|
||||
|
||||
Reference in new issue
Block a user