mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
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:
+5
-10
@@ -64,17 +64,12 @@ func (e *Enum) Update(gtx layout.Context) bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
filters := []event.Filter{
|
||||
key.FocusFilter{Target: &state.tag},
|
||||
}
|
||||
if e.focused && e.focus == state.key {
|
||||
filters = append(filters,
|
||||
key.Filter{Target: &state.tag, Name: key.NameReturn},
|
||||
key.Filter{Target: &state.tag, Name: key.NameSpace},
|
||||
)
|
||||
}
|
||||
for {
|
||||
ev, ok := gtx.Event(filters...)
|
||||
ev, ok := gtx.Event(
|
||||
key.FocusFilter{Target: &state.tag},
|
||||
key.Filter{Focus: &state.tag, Name: key.NameReturn},
|
||||
key.Filter{Focus: &state.tag, Name: key.NameSpace},
|
||||
)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user