Skip to content

Commit cf34453

Browse files
committed
[Find/Replace][Win] grab focus when just opened
Solves arduino#6951 (comment)
1 parent 99180ce commit cf34453

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: app/src/cc/arduino/view/findreplace/FindReplace.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ public FindReplace(Editor editor, Map<String, Object> state) {
6262
isTranslucencySupported();
6363
initComponents();
6464

65-
if (OSUtils.isWindows()) {
66-
setAutoRequestFocus(false);
67-
}
68-
6965
if (OSUtils.isMacOS()) {
7066
buttonsContainer.removeAll();
7167
buttonsContainer.add(replaceAllButton);
@@ -76,6 +72,9 @@ public FindReplace(Editor editor, Map<String, Object> state) {
7672
}
7773

7874
Base.registerWindowCloseKeys(getRootPane(), e -> {
75+
if (OSUtils.isWindows()) {
76+
setAutoRequestFocus(true);
77+
}
7978
setVisible(false);
8079
Base.FIND_DIALOG_STATE = findDialogState();
8180
});
@@ -86,6 +85,7 @@ public FindReplace(Editor editor, Map<String, Object> state) {
8685
public void windowActivated(WindowEvent e) {
8786
if (OSUtils.isWindows()) {
8887
toFront();
88+
setAutoRequestFocus(false);
8989
return;
9090
}
9191
findField.requestFocusInWindow();
@@ -128,6 +128,11 @@ public void windowDeactivated(WindowEvent e) {
128128
public void setVisible(boolean b) {
129129
getRootPane().setDefaultButton(findButton);
130130

131+
if (OSUtils.isWindows()) {
132+
// means we are restoring the window visibility
133+
setAutoRequestFocus(true);
134+
}
135+
131136
super.setVisible(b);
132137
}
133138

0 commit comments

Comments
 (0)