esc works
This commit is contained in:
parent
34295c9313
commit
c2a5226c0c
@ -221,6 +221,7 @@ public class MainWindow extends JFrame {
|
|||||||
|
|
||||||
commandLine = new JTextField();
|
commandLine = new JTextField();
|
||||||
commandLine.setFont(new Font("Monospaced", Font.PLAIN, 12));
|
commandLine.setFont(new Font("Monospaced", Font.PLAIN, 12));
|
||||||
|
commandLine.setFocusTraversalKeysEnabled(false);
|
||||||
commandLine.addActionListener(e -> executeCommand(commandLine.getText()));
|
commandLine.addActionListener(e -> executeCommand(commandLine.getText()));
|
||||||
|
|
||||||
// Let the panels catch focus back if user presses ESC or TAB in command line
|
// Let the panels catch focus back if user presses ESC or TAB in command line
|
||||||
@ -229,10 +230,10 @@ public class MainWindow extends JFrame {
|
|||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||||
commandLine.setText("");
|
commandLine.setText("");
|
||||||
activePanel.getFileTable().requestFocus();
|
activePanel.getFileTable().requestFocusInWindow();
|
||||||
e.consume();
|
e.consume();
|
||||||
} else if (e.getKeyCode() == KeyEvent.VK_TAB) {
|
} else if (e.getKeyCode() == KeyEvent.VK_TAB) {
|
||||||
activePanel.getFileTable().requestFocus();
|
activePanel.getFileTable().requestFocusInWindow();
|
||||||
e.consume();
|
e.consume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,10 +560,8 @@ public class MainWindow extends JFrame {
|
|||||||
// ESC - global escape to return focus to panels
|
// ESC - global escape to return focus to panels
|
||||||
rootPane.registerKeyboardAction(e -> {
|
rootPane.registerKeyboardAction(e -> {
|
||||||
if (activePanel != null) {
|
if (activePanel != null) {
|
||||||
// If it's the command line, clear it too (though it has its own listener)
|
// Always clear command line and return focus to panels
|
||||||
if (commandLine.hasFocus()) {
|
commandLine.setText("");
|
||||||
commandLine.setText("");
|
|
||||||
}
|
|
||||||
activePanel.getFileTable().requestFocusInWindow();
|
activePanel.getFileTable().requestFocusInWindow();
|
||||||
}
|
}
|
||||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
|
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
|
||||||
@ -782,6 +781,7 @@ public class MainWindow extends JFrame {
|
|||||||
} else {
|
} else {
|
||||||
commandLine.setText(current + toAdd);
|
commandLine.setText(current + toAdd);
|
||||||
}
|
}
|
||||||
|
commandLine.requestFocusInWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user