Skip to content

Commit 128bad6

Browse files
committed
GP-4328 - Fix for recent tab pane regression
1 parent 4f95fdd commit 128bad6

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Ghidra/Framework/Docking/src/main/java/docking/ComponentNode.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -339,26 +339,28 @@ private int addComponentsToTabbedPane(List<ComponentPlaceholder> activeComponent
339339
}
340340

341341
private void setupFocusUpdateListeners(JTabbedPane tabbedPane) {
342-
registerSpacebarActionToTransferFocusToTabbedComponent(tabbedPane);
342+
registerActionToTransferFocusToTabbedComponent(tabbedPane);
343343
tabbedPane.addMouseListener(new MouseAdapter() {
344344
@Override
345345
public void mousePressed(MouseEvent e) {
346346
int index = tabbedPane.indexAtLocation(e.getX(), e.getY());
347-
Component selectedComponent = tabbedPane.getComponentAt(index);
348-
focusComponent(selectedComponent);
347+
if (index >= 0) {
348+
Component selectedComponent = tabbedPane.getComponentAt(index);
349+
focusComponent(selectedComponent);
350+
}
349351
}
350352
});
351353
}
352354

353355
/**
354-
* Registers a keybinding that binds VK_SPACE to an action that transfers focus the
355-
* component represented by the currently focussed tab of a JTabbedPane. This is so that
356-
* when using keyboard focus traversal and the JTabbedPane get focus such that using arrow
357-
* keys allows the user to switch tabs, pressing the spacebar will transfer control to the
358-
* currently focused tab.
359-
* @param tabbedPane the JTabbedPane to add this spacebar keybinding.
356+
* Registers a keybinding that allows the user to press the space bar to transfer focus to the
357+
* component inside of the current tab of the tabbed pane. When using keyboard navigation, the
358+
* tabbed pane will place focus on its tabs, not on the components in the tabs. Adding the
359+
* space bar trigger makes keyboard navigation easier by giving the user a method to focus the
360+
* component represented by the tab.
361+
* @param tabbedPane the JTabbedPane
360362
*/
361-
private void registerSpacebarActionToTransferFocusToTabbedComponent(JTabbedPane tabbedPane) {
363+
private void registerActionToTransferFocusToTabbedComponent(JTabbedPane tabbedPane) {
362364
Action focusAction = new AbstractAction("Focus") {
363365
@Override
364366
public void actionPerformed(ActionEvent ev) {

0 commit comments

Comments
 (0)