Window attempts to advance child's selection on alt-tab
This commit is contained in:
parent
507217a9da
commit
80c0a6be71
@ -66,11 +66,34 @@ func (window *Window) handleKeyPress (
|
|||||||
NumberPad: numberPad,
|
NumberPad: numberPad,
|
||||||
}
|
}
|
||||||
|
|
||||||
window.child.Handle (tomo.EventKeyDown {
|
keyDownEvent := tomo.EventKeyDown {
|
||||||
Key: key,
|
Key: key,
|
||||||
Modifiers: modifiers,
|
Modifiers: modifiers,
|
||||||
Repeated: false, // FIXME: return correct value here
|
Repeated: false, // FIXME: return correct value here
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if keyDownEvent.Key == tomo.KeyTab && keyDownEvent.Modifiers.Alt {
|
||||||
|
if window.child.Selectable() {
|
||||||
|
direction := 1
|
||||||
|
if keyDownEvent.Modifiers.Shift {
|
||||||
|
direction = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
window.advanceSelectionInChild(direction)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.child.Handle(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (window *Window) advanceSelectionInChild (direction int) {
|
||||||
|
if window.child.Selected() {
|
||||||
|
if !window.child.AdvanceSelection(direction) {
|
||||||
|
window.child.Handle(tomo.EventDeselect { })
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.child.Handle(tomo.EventSelect { })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (window *Window) handleKeyRelease (
|
func (window *Window) handleKeyRelease (
|
||||||
|
17
tomo.go
17
tomo.go
@ -92,17 +92,18 @@ type Element interface {
|
|||||||
// element contains other selectable elements, it must return true.
|
// element contains other selectable elements, it must return true.
|
||||||
Selectable () (selectable bool)
|
Selectable () (selectable bool)
|
||||||
|
|
||||||
// Selected returns wehther this element is currently selected. This
|
// Selected returns whether or not this element is currently selected.
|
||||||
// will always return false if it is not selectable.
|
// This will always return false if it is not selectable.
|
||||||
Selected () (selected bool)
|
Selected () (selected bool)
|
||||||
|
|
||||||
// If this element contains other elements, and one is selected, this
|
// If this element contains other elements, and one is selected, this
|
||||||
// method will advance the selection in the specified direction. If no
|
// method will advance the selection in the specified direction. If
|
||||||
// children are selected, or there are no more children to be selected
|
// the element contains selectable elements but none of them are
|
||||||
// in the specified direction, the element will unselect all of its
|
// selected, it will select the first selectable element. If there are
|
||||||
// children and return false. If the selection could be advanced, it
|
// no more children to be selected in the specified direction, the
|
||||||
// will return true. If the element contains no child elements, it will
|
// element will return false. If the selection could be advanced, it
|
||||||
// always return false.
|
// will return true. If the element contains no selectable child
|
||||||
|
// elements, it will always return false.
|
||||||
AdvanceSelection (direction int) (ok bool)
|
AdvanceSelection (direction int) (ok bool)
|
||||||
|
|
||||||
// SetParentHooks gives the element callbacks that let it send
|
// SetParentHooks gives the element callbacks that let it send
|
||||||
|
Reference in New Issue
Block a user