mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
io/router,app: scroll a bit when reaching the end in a focus direction
List was recently changed to include an extra child at each end, to automatically scroll when reaching the end of a focus direction. However, if List includes unfocusable children that strategy may fail. This change adds another fallback where app.Window will scroll a constant amount in the focus direction, to reveal more children. For https://github.com/tailscale/tailscale/issues/4278. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+6
-1
@@ -169,7 +169,8 @@ func (q *keyQueue) updateFocusLayout() {
|
||||
}
|
||||
}
|
||||
|
||||
func (q *keyQueue) MoveFocus(dir FocusDirection, events *handlerEvents) {
|
||||
// MoveFocus attempts to move the focus in the direction of dir, returning true if it succeeds.
|
||||
func (q *keyQueue) MoveFocus(dir FocusDirection, events *handlerEvents) bool {
|
||||
order := 0
|
||||
if q.focus != nil {
|
||||
order = q.handlers[q.focus].dirOrder
|
||||
@@ -194,6 +195,7 @@ func (q *keyQueue) MoveFocus(dir FocusDirection, events *handlerEvents) {
|
||||
}
|
||||
order = (order + len(q.order)) % len(q.order)
|
||||
q.setFocus(q.order[order], events)
|
||||
return true
|
||||
case FocusRight, FocusLeft:
|
||||
next := order
|
||||
if q.focus != nil {
|
||||
@@ -206,6 +208,7 @@ func (q *keyQueue) MoveFocus(dir FocusDirection, events *handlerEvents) {
|
||||
newFocus := q.dirOrder[next]
|
||||
if newFocus.row == focus.row {
|
||||
q.setFocus(newFocus.tag, events)
|
||||
return true
|
||||
}
|
||||
}
|
||||
case FocusUp, FocusDown:
|
||||
@@ -242,8 +245,10 @@ func (q *keyQueue) MoveFocus(dir FocusDirection, events *handlerEvents) {
|
||||
}
|
||||
if closest != nil {
|
||||
q.setFocus(closest, events)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (q *keyQueue) Push(e event.Event, events *handlerEvents) {
|
||||
|
||||
Reference in New Issue
Block a user