mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +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:
@@ -1177,6 +1177,29 @@ func TestEditor_Submit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoFilterAllocs(t *testing.T) {
|
||||
b := testing.Benchmark(func(b *testing.B) {
|
||||
r := new(input.Router)
|
||||
e := new(Editor)
|
||||
gtx := layout.Context{
|
||||
Ops: new(op.Ops),
|
||||
Constraints: layout.Constraints{
|
||||
Max: image.Pt(100, 100),
|
||||
},
|
||||
Locale: english,
|
||||
Source: r.Source(),
|
||||
}
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
e.Update(gtx)
|
||||
}
|
||||
})
|
||||
if allocs := b.AllocsPerOp(); allocs != 0 {
|
||||
t.Fatalf("expected 0 AllocsPerOp, got %d", allocs)
|
||||
}
|
||||
}
|
||||
|
||||
// textWidth is a text helper for building simple selection events.
|
||||
// It assumes single-run lines, which isn't safe with non-test text
|
||||
// data.
|
||||
|
||||
Reference in New Issue
Block a user