1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-26 20:54:22 +01:00

[Find/Replace][Win] grab focus when just opened

Solves https://github.com/arduino/Arduino/issues/6951#issuecomment-351995084
This commit is contained in:
Martino Facchin 2018-01-15 14:28:32 +01:00 committed by Cristian Maglie
parent ce70d66095
commit 71418caa4b

View File

@ -62,10 +62,6 @@ public class FindReplace extends javax.swing.JFrame {
isTranslucencySupported();
initComponents();
if (OSUtils.isWindows()) {
setAutoRequestFocus(false);
}
if (OSUtils.isMacOS()) {
buttonsContainer.removeAll();
buttonsContainer.add(replaceAllButton);
@ -76,6 +72,9 @@ public class FindReplace extends javax.swing.JFrame {
}
Base.registerWindowCloseKeys(getRootPane(), e -> {
if (OSUtils.isWindows()) {
setAutoRequestFocus(true);
}
setVisible(false);
Base.FIND_DIALOG_STATE = findDialogState();
});
@ -86,6 +85,7 @@ public class FindReplace extends javax.swing.JFrame {
public void windowActivated(WindowEvent e) {
if (OSUtils.isWindows()) {
toFront();
setAutoRequestFocus(false);
return;
}
findField.requestFocusInWindow();
@ -128,6 +128,11 @@ public class FindReplace extends javax.swing.JFrame {
public void setVisible(boolean b) {
getRootPane().setDefaultButton(findButton);
if (OSUtils.isWindows()) {
// means we are restoring the window visibility
setAutoRequestFocus(true);
}
super.setVisible(b);
}