Skip to content

Commit bb6edd6

Browse files
authored
Fix multiple carets blinking in text boxes (#6452)
1 parent 97bb049 commit bb6edd6

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/main/java/meteordevelopment/meteorclient/gui/WidgetScreen.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ public boolean mouseClicked(MouseButtonEvent click, boolean doubled) {
129129
mouseX *= s;
130130
mouseY *= s;
131131

132+
// Unfocus all text boxes that are not under the mouse cursor
133+
loopWidgets(root, widget -> {
134+
if (widget instanceof WTextBox textBox && textBox.isFocused() && !textBox.mouseOver) {
135+
textBox.setFocused(false);
136+
}
137+
});
138+
132139
return root.mouseClicked(new MouseButtonEvent(mouseX, mouseY, click.buttonInfo()), doubled);
133140
}
134141

@@ -337,9 +344,17 @@ public void removed() {
337344
}
338345

339346
if (onClose) {
347+
double restoreX = lastMouseX / mc.getWindow().getGuiScale();
348+
double restoreY = lastMouseY / mc.getWindow().getGuiScale();
349+
340350
taskAfterRender = () -> {
341351
locked = true;
342352
mc.setScreen(parent);
353+
354+
// Restore mouse position to where it was when the screen was closed
355+
if (parent == null) {
356+
glfwSetCursorPos(mc.getWindow().handle(), restoreX, restoreY);
357+
}
343358
};
344359
}
345360
}

src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/widgets/input/WMeteorTextBox.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public String getCompletion() {
9393
protected void onCursorChanged() {
9494
cursorVisible = true;
9595
cursorTimer = 0;
96+
animProgress = focused ? 1.0 : 0.0;
9697
}
9798

9899
@Override
@@ -139,4 +140,4 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub
139140

140141
renderer.scissorEnd();
141142
}
142-
}
143+
}

0 commit comments

Comments
 (0)