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(fullViewItem);
|
||||||
viewMenu.add(briefViewItem);
|
viewMenu.add(briefViewItem);
|
||||||
|
|
||||||
// Settings menu
|
// Settings menu
|
||||||
JMenu settingsMenu = new JMenu("Settings");
|
JMenu settingsMenu = new JMenu("Settings");
|
||||||
JMenuItem appearanceItem = new JMenuItem("Appearance...");
|
settingsMenu.setMnemonic(KeyEvent.VK_O);
|
||||||
appearanceItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_DOWN_MASK));
|
settingsMenu.addMouseListener(new MouseAdapter() {
|
||||||
appearanceItem.addActionListener(e -> showSettingsDialog());
|
@Override
|
||||||
settingsMenu.add(appearanceItem);
|
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
|
// Help menu
|
||||||
JMenu helpMenu = new JMenu("Help");
|
JMenu helpMenu = new JMenu("Help");
|
||||||
|
|
||||||
JMenuItem aboutItem = new JMenuItem("About");
|
JMenuItem aboutItem = new JMenuItem("About");
|
||||||
aboutItem.addActionListener(e -> showAboutDialog());
|
aboutItem.addActionListener(e -> showAboutDialog());
|
||||||
@ -1108,10 +1122,6 @@ public class MainWindow extends JFrame {
|
|||||||
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK),
|
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK),
|
||||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
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)
|
table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
|
||||||
.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK), "wildcardSelect");
|
.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() {
|
table.getActionMap().put("wildcardSelect", new AbstractAction() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@ -1311,7 +1323,8 @@ public class MainWindow extends JFrame {
|
|||||||
char c = e.getKeyChar();
|
char c = e.getKeyChar();
|
||||||
// Transfer to command line only for printable characters and when no modifiers like Ctrl or Alt are pressed.
|
// 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.
|
// 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();
|
commandLine.requestFocusInWindow();
|
||||||
String current = commandLine.getEditor().getItem().toString();
|
String current = commandLine.getEditor().getItem().toString();
|
||||||
commandLine.getEditor().setItem(current + c);
|
commandLine.getEditor().setItem(current + c);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user