Skip to content

Commit

Permalink
adding ctrl+shift+W (or command+shift+W for Mac) for result tab closure
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmipt committed Jan 5, 2024
1 parent 7d118d2 commit 7e6efcf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/studio/ui/ClosableTabbedPane.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package studio.ui;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import static javax.swing.JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT;

public class ClosableTabbedPane {

public interface CloseTabAction {
Expand Down Expand Up @@ -51,6 +54,13 @@ private boolean checkPopup(int tabIndex, MouseEvent e) {
}
});

tabbedPane.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_W, StudioWindow.menuShortcutKeyMask | KeyEvent.SHIFT_MASK), "closeTab");
tabbedPane.getActionMap().put("closeTab",
UserAction.create("Close tab", e -> {
int index = tabbedPane.getSelectedIndex();
if (index != -1) closeTabAction.close(index, true);
}) );

}

private static JPopupMenu createTabbedPopupMenu(JTabbedPane tabbedPane, CloseTabAction closeTabAction, int index) {
Expand Down

0 comments on commit 7e6efcf

Please sign in to comment.