forked from joejulian/gio
io/router,app: move Tab-to-focus conversion to app.Window
This is a refactor to make it easier to add higher level logic to focus moves. A follow-up will add automatic scrolling to bring focused widgets into view. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+5
-21
@@ -227,27 +227,6 @@ func TestNoOps(t *testing.T) {
|
||||
r.Frame(nil)
|
||||
}
|
||||
|
||||
func TestTabFocus(t *testing.T) {
|
||||
handlers := make([]int, 3)
|
||||
ops := new(op.Ops)
|
||||
r := new(Router)
|
||||
|
||||
for i := range handlers {
|
||||
key.InputOp{Tag: &handlers[i]}.Add(ops)
|
||||
}
|
||||
r.Frame(ops)
|
||||
|
||||
tab := func(mod key.Modifiers) {
|
||||
r.Queue(
|
||||
key.Event{Name: key.NameTab, State: key.Press, Modifiers: mod},
|
||||
key.Event{Name: key.NameTab, State: key.Release, Modifiers: mod},
|
||||
)
|
||||
}
|
||||
tab(0)
|
||||
tab(key.ModShift)
|
||||
assertFocus(t, r, &handlers[2])
|
||||
}
|
||||
|
||||
func TestDirectionalFocus(t *testing.T) {
|
||||
ops := new(op.Ops)
|
||||
r := new(Router)
|
||||
@@ -281,6 +260,11 @@ func TestDirectionalFocus(t *testing.T) {
|
||||
assertFocus(t, r, &handlers[3])
|
||||
r.MoveFocus(FocusUp)
|
||||
assertFocus(t, r, &handlers[0])
|
||||
|
||||
r.MoveFocus(FocusForward)
|
||||
assertFocus(t, r, &handlers[1])
|
||||
r.MoveFocus(FocusBackward)
|
||||
assertFocus(t, r, &handlers[0])
|
||||
}
|
||||
|
||||
func assertKeyEvent(t *testing.T, events []event.Event, expected bool, expectedInputs ...event.Event) {
|
||||
|
||||
Reference in New Issue
Block a user