Skip to content

Commit 709827f

Browse files
authored
Initial commit updating search focus behavior
1 parent e460464 commit 709827f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/main/java/com/refinedmods/refinedstorage/screen/widget/SearchWidget.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,22 @@ private boolean canSyncFromJEINow() {
4747

4848
@Override
4949
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
50-
boolean wasFocused = isFocused();
51-
5250
boolean result = super.mouseClicked(mouseX, mouseY, mouseButton);
53-
5451
boolean clickedWidget = mouseX >= this.getX() && mouseX < this.getX() + this.width && mouseY >= this.getY() && mouseY < this.getY() + this.height;
5552

5653
if (clickedWidget && mouseButton == 1) {
54+
// On right click, clear the widget and focus, save history if necessary.
55+
if (isFocused()) {
56+
saveHistory()
57+
}
5758
setValue("");
5859
setFocused(true);
59-
} else if (wasFocused != isFocused()) {
60+
}
61+
62+
if (!clickedWidget && isFocused()) {
63+
// If we are focused, and we click outside the search box, lose focus.
6064
saveHistory();
65+
setFocused(false);
6166
}
6267

6368
return result;

0 commit comments

Comments
 (0)