■ ■ ■ ■ ■ ■
jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java
| skipped 72 lines |
73 | 73 | | } |
74 | 74 | | }); |
75 | 75 | | interceptTabKey(); |
| 76 | + | interceptCloseKey(); |
76 | 77 | | enableSwitchingTabs(); |
77 | 78 | | } |
78 | 79 | | |
| skipped 37 lines |
116 | 117 | | } |
117 | 118 | | } |
118 | 119 | | return consume; |
| 120 | + | } |
| 121 | + | }); |
| 122 | + | } |
| 123 | + | |
| 124 | + | private void interceptCloseKey() { |
| 125 | + | KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() { |
| 126 | + | private static final int closeKey = KeyEvent.VK_W; |
| 127 | + | private boolean canClose = true; |
| 128 | + | |
| 129 | + | @Override |
| 130 | + | public boolean dispatchKeyEvent(KeyEvent e) { |
| 131 | + | if (!FocusManager.isActive()) { |
| 132 | + | return false; // do nothing when tab is not on focus. |
| 133 | + | } |
| 134 | + | if (e.getKeyCode() != closeKey) { |
| 135 | + | return false; // only intercept the events of the close key |
| 136 | + | } |
| 137 | + | if (e.getID() == KeyEvent.KEY_RELEASED) { |
| 138 | + | canClose = true; // after the close key is lifted we allow to use it again |
| 139 | + | return false; |
| 140 | + | } |
| 141 | + | if (e.isControlDown() && canClose) { |
| 142 | + | // close the current tab |
| 143 | + | closeCodePanel(curTab); |
| 144 | + | canClose = false; // make sure we dont close more tabs until the close key is lifted |
| 145 | + | return true; |
| 146 | + | } |
| 147 | + | return false; |
119 | 148 | | } |
120 | 149 | | }); |
121 | 150 | | } |
| skipped 332 lines |