added + support
This commit is contained in:
parent
2f0e1df9c9
commit
4624e9f8d4
@ -771,15 +771,29 @@ public class MainWindow extends JFrame {
|
||||
viewMenu.add(fullViewItem);
|
||||
viewMenu.add(briefViewItem);
|
||||
|
||||
// Settings menu
|
||||
JMenu settingsMenu = new JMenu("Settings");
|
||||
JMenuItem appearanceItem = new JMenuItem("Appearance...");
|
||||
appearanceItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_DOWN_MASK));
|
||||
appearanceItem.addActionListener(e -> showSettingsDialog());
|
||||
settingsMenu.add(appearanceItem);
|
||||
|
||||
// Help menu
|
||||
JMenu helpMenu = new JMenu("Help");
|
||||
// Settings menu
|
||||
JMenu settingsMenu = new JMenu("Settings");
|
||||
settingsMenu.setMnemonic(KeyEvent.VK_O);
|
||||
settingsMenu.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (SwingUtilities.isLeftMouseButton(e)) {
|
||||
showSettingsDialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
// Add key binding for Alt+O since JMenu doesn't support accelerators directly
|
||||
settingsMenu.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_DOWN_MASK), "openSettings");
|
||||
settingsMenu.getActionMap().put("openSettings", new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showSettingsDialog();
|
||||
}
|
||||
});
|
||||
|
||||
// Help menu
|
||||
JMenu helpMenu = new JMenu("Help");
|
||||
|
||||
JMenuItem aboutItem = new JMenuItem("About");
|
||||
aboutItem.addActionListener(e -> showAboutDialog());
|
||||
@ -1108,10 +1122,6 @@ public class MainWindow extends JFrame {
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK),
|
||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
// Ctrl+A - Select files by wildcard
|
||||
rootPane.registerKeyboardAction(e -> showWildcardSelectDialog(),
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK),
|
||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1270,9 +1280,11 @@ public class MainWindow extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
// Wildcard selection (Ctrl+A)
|
||||
// Wildcard selection (Ctrl+A and +)
|
||||
table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
|
||||
.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK), "wildcardSelect");
|
||||
table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
|
||||
.put(KeyStroke.getKeyStroke('+'), "wildcardSelect");
|
||||
table.getActionMap().put("wildcardSelect", new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -1311,7 +1323,8 @@ public class MainWindow extends JFrame {
|
||||
char c = e.getKeyChar();
|
||||
// Transfer to command line only for printable characters and when no modifiers like Ctrl or Alt are pressed.
|
||||
// This prevents focus jump on shortcuts like Ctrl+C, Ctrl+V, etc.
|
||||
if (c != KeyEvent.CHAR_UNDEFINED && c >= 32 && c != 127 && !e.isControlDown() && !e.isAltDown()) {
|
||||
// Exclude '+' as it is used for wildcard selection.
|
||||
if (c != KeyEvent.CHAR_UNDEFINED && c >= 32 && c != 127 && c != '+' && !e.isControlDown() && !e.isAltDown()) {
|
||||
commandLine.requestFocusInWindow();
|
||||
String current = commandLine.getEditor().getItem().toString();
|
||||
commandLine.getEditor().setItem(current + c);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user