Skip to content

Commit

Permalink
Fix find/replace focus on Windows
Browse files Browse the repository at this point in the history
Probably this approach could be adopted by all OSes with a little care on the window lifecycle.
  • Loading branch information
facchinm committed Nov 13, 2017
1 parent 62246ba commit 0d50f0b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/src/cc/arduino/view/findreplace/FindReplace.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public FindReplace(Editor editor, Map<String, Object> state) {
isTranslucencySupported();
initComponents();

if (OSUtils.isWindows()) {
setAutoRequestFocus(false);
}

if (OSUtils.isMacOS()) {
buttonsContainer.removeAll();
buttonsContainer.add(replaceAllButton);
Expand All @@ -80,6 +84,10 @@ public FindReplace(Editor editor, Map<String, Object> state) {

editor.addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
if (OSUtils.isWindows()) {
toFront();
return;
}
findField.requestFocusInWindow();
findField.selectAll();
setAlwaysOnTop(true);
Expand All @@ -89,12 +97,18 @@ public void windowActivated(WindowEvent e) {
}
}
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);
Expand Down

0 comments on commit 0d50f0b

Please sign in to comment.