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

Fix find/replace focus on Windows

Probably this approach could be adopted by all OSes with a little care on the window lifecycle.
This commit is contained in:
Martino Facchin 2017-10-09 17:12:29 +02:00 committed by Cristian Maglie
parent 449c99a2f5
commit ce70d66095

View File

@ -62,6 +62,10 @@ public class FindReplace extends javax.swing.JFrame {
isTranslucencySupported();
initComponents();
if (OSUtils.isWindows()) {
setAutoRequestFocus(false);
}
if (OSUtils.isMacOS()) {
buttonsContainer.removeAll();
buttonsContainer.add(replaceAllButton);
@ -80,6 +84,10 @@ public class FindReplace extends javax.swing.JFrame {
editor.addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
if (OSUtils.isWindows()) {
toFront();
return;
}
findField.requestFocusInWindow();
findField.selectAll();
setAlwaysOnTop(true);
@ -89,12 +97,18 @@ public class FindReplace extends javax.swing.JFrame {
}
}
public void windowDeactivated(WindowEvent e) {
if (OSUtils.isWindows()) {
return;
}
setAlwaysOnTop(false);
}
});
addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
if (OSUtils.isWindows()) {
return;
}
findField.requestFocusInWindow();
findField.selectAll();
setAlwaysOnTop(true);