mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-13 10:29:35 +01:00
Replace requestFocus()
by requestFocusInWindow()
where applicable
The former gives focus to the window in which a component is present, while the latter only changes the focus within the current window (not focusing the window itself if it is not focused yet). Java documentation recommends changing `requestFocusInWindow()` where possible, due to some platform-dependent behaviour in `requestFocus()`. When focusing the serial monitor and plotter, `requestFocus()` is still used, since then the focused window *should* change.
This commit is contained in:
parent
f57b90c1c8
commit
1d21378a5f
@ -1608,7 +1608,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
codePanel.removeAll();
|
||||
codePanel.add(tabs.get(index), BorderLayout.CENTER);
|
||||
tabs.get(index).requestFocus(); // get the caret blinking
|
||||
tabs.get(index).requestFocusInWindow(); // get the caret blinking
|
||||
// For some reason, these are needed. Revalidate says it should be
|
||||
// automatically called when components are added or removed, but without
|
||||
// it, the component switched to is not displayed. repaint() is needed to
|
||||
|
@ -147,7 +147,7 @@ public class EditorStatus extends JPanel {
|
||||
editField.setVisible(true);
|
||||
editField.setText(dflt);
|
||||
editField.selectAll();
|
||||
editField.requestFocus();
|
||||
editField.requestFocusInWindow();
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
@ -600,9 +600,9 @@ public class EditorTab extends JPanel implements SketchCode.TextStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFocus() {
|
||||
public boolean requestFocusInWindow() {
|
||||
/** If focus is requested, focus the textarea instead. */
|
||||
textarea.requestFocus();
|
||||
return textarea.requestFocusInWindow();
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user