io/input: permit FocusCmd to explicitly set the focus to any tag

If the client asks for the focus to be set to a tag, allow it. There is a
check at the end of Router.Frame that clears the focus if the tag turns
out to fail the requirements (visible and has asked for FocusEvents).

The change simplifies the logic for determining whether a command can
be executed immediately.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-11-26 11:23:52 -06:00
parent 8e209fd2eb
commit 496fc3cc82
3 changed files with 23 additions and 46 deletions
-5
View File
@@ -281,11 +281,6 @@ func keyFilterMatch(f key.Filter, e key.Event) bool {
}
func (q *keyQueue) Focus(handlers map[event.Tag]*handler, state keyState, focus event.Tag) (keyState, []taggedEvent) {
if focus != nil {
if h, exists := handlers[focus]; !exists || !h.filter.key.focusable || !h.key.visible {
focus = nil
}
}
if focus == state.focus {
return state, nil
}