HotKey can set focus
- Fix AbstractView to return focus info for hotkey handler - TerminalUI sets focus from returned key handling for hotkeys - Fixes #881
This commit is contained in:
@@ -273,6 +273,9 @@ public class TerminalUI implements ViewService {
|
||||
if (handler != null) {
|
||||
KeyHandlerResult result = handler.handle(KeyHandler.argsOf(event));
|
||||
if (result.consumed()) {
|
||||
if (result.focus() != null) {
|
||||
setFocus(result.focus());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,16 +189,18 @@ public abstract class AbstractView extends AbstractControl implements View {
|
||||
log.trace("getHotKeyHandler() {}", this);
|
||||
KeyHandler handler = args -> {
|
||||
KeyEvent event = args.event();
|
||||
View view = null;
|
||||
boolean consumed = false;
|
||||
Integer key = event.key();
|
||||
if (key != null) {
|
||||
KeyBindingValue keyBindingValue = getHotKeyBindings().get(key);
|
||||
if (keyBindingValue != null) {
|
||||
view = this;
|
||||
consumed = dispatchKeyRunCommand(event, keyBindingValue);
|
||||
}
|
||||
|
||||
}
|
||||
return KeyHandler.resultOf(event, consumed, null);
|
||||
return KeyHandler.resultOf(event, consumed, view);
|
||||
};
|
||||
return handler;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user