all: [API] deliver key events to the first matching filter

Replace the key.Filter.Target field with a Focus field that matches only
of the specified tag has focus. This has the advantage of simpler event
delivery and for lower latency in delivering key events to new handlers.

For example, consider a UI where a button is activated by a key press,
which is turn displays a dialog with another button activated by the
same key. This change allows two button press(+releases) in the same frame
to arrive at the intended targets: one key press(+release) for each
button.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-11-26 17:54:51 -06:00
parent d9a007586c
commit ed0d5d5767
9 changed files with 169 additions and 184 deletions
+4 -8
View File
@@ -1,12 +1,6 @@
// SPDX-License-Identifier: Unlicense OR MIT
/*
Package key implements key and text events and operations.
The InputOp operations is used for declaring key input handlers. Use
an implementation of the Queue interface from package ui to receive
events.
*/
// Package key implements key and text events and operations.
package key
import (
@@ -20,7 +14,9 @@ import (
// Filter matches any [Event] that matches the parameters.
type Filter struct {
Target event.Tag
// Focus is the tag that must be focused for the filter to match. It has no effect
// if it is nil.
Focus event.Tag
// Required is the set of modifiers that must be included in events matched.
Required Modifiers
// Optional is the set of modifiers that may be included in events matched.