mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-2894 - Key Bindings - fixed bug in Structure Editor that prevented
toolbar action keybinding from working; updated all keybindings to work with focus in text components when the binding is modified, as long as the component does itself not have an action registered for that binding
This commit is contained in:
parent
73f3b83bc3
commit
28c5218f18
2 changed files with 27 additions and 12 deletions
|
@ -202,7 +202,7 @@ class KeyBindingOverrideKeyEventDispatcher implements KeyEventDispatcher {
|
|||
|
||||
// note: this call has no effect if 'action' is null
|
||||
SwingUtilities.notifyAction(action, keyStroke, event, event.getSource(),
|
||||
event.getModifiers());
|
||||
event.getModifiersEx());
|
||||
|
||||
}
|
||||
return wasInProgress;
|
||||
|
@ -254,8 +254,30 @@ class KeyBindingOverrideKeyEventDispatcher implements KeyEventDispatcher {
|
|||
// }
|
||||
|
||||
// We've made the executive decision to allow all keys to go through to the text component
|
||||
// unless they are modified with the 'Alt' key
|
||||
return !event.isAltDown();
|
||||
// unless they are modified with the 'Alt'/'Ctrl'/etc keys, unless they directly used
|
||||
// by the text component
|
||||
if (!isNonTextModifierOn(event)) {
|
||||
return true; // unmodified keys will be given to the text component
|
||||
}
|
||||
|
||||
// the key is modified; let it through if the component has a mapping for the key
|
||||
return hasComponentKeyToActionMapping((JTextComponent) destination, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* A test to see if the given event is modified in such a way as a text component would not
|
||||
* handle the event
|
||||
* @param e the event
|
||||
* @return true if modified
|
||||
*/
|
||||
private boolean isNonTextModifierOn(KeyEvent e) {
|
||||
return e.isAltDown() || e.isAltGraphDown() || e.isMetaDown() || e.isControlDown();
|
||||
}
|
||||
|
||||
private boolean hasComponentKeyToActionMapping(JComponent c, KeyEvent event) {
|
||||
KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(event);
|
||||
Action action = getJavaActionForComponent(c, keyStroke);
|
||||
return action != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,7 +393,7 @@ class KeyBindingOverrideKeyEventDispatcher implements KeyEventDispatcher {
|
|||
Action action = getJavaActionForComponent(jComponent, keyStroke);
|
||||
if (action != null) {
|
||||
return SwingUtilities.notifyAction(action, keyStroke, keyEvent, keyEvent.getSource(),
|
||||
keyEvent.getModifiers());
|
||||
keyEvent.getModifiersEx());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue