Propagate keyboard events to root if nothing is focused
This makes window-level keybinds possible. Exciting!
This commit is contained in:
parent
6ff5dea308
commit
85b8536925
@ -24,13 +24,19 @@ func (this *Hierarchy) HandleModifiers (modifiers input.Modifiers) {
|
|||||||
// HandleModifiers must be called *before* HandleKeyDown.
|
// HandleModifiers must be called *before* HandleKeyDown.
|
||||||
func (this *Hierarchy) HandleKeyDown (key input.Key, numberPad bool) {
|
func (this *Hierarchy) HandleKeyDown (key input.Key, numberPad bool) {
|
||||||
caught := false
|
caught := false
|
||||||
this.keyboardTargets(func (target anyBox) bool {
|
if this.anyFocused() {
|
||||||
if target.handleKeyDown(key, numberPad) {
|
this.keyboardTargets(func (target anyBox) bool {
|
||||||
caught = true
|
if target.handleKeyDown(key, numberPad) {
|
||||||
return false
|
caught = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if this.root != nil {
|
||||||
|
caught = this.root.handleKeyDown(key, numberPad)
|
||||||
}
|
}
|
||||||
return true
|
}
|
||||||
})
|
|
||||||
if caught { return }
|
if caught { return }
|
||||||
|
|
||||||
switch key {
|
switch key {
|
||||||
@ -49,12 +55,18 @@ func (this *Hierarchy) HandleKeyDown (key input.Key, numberPad bool) {
|
|||||||
// which triggers this comes with modifier key information, HandleModifiers must
|
// which triggers this comes with modifier key information, HandleModifiers must
|
||||||
// be called *before* HandleKeyUp.
|
// be called *before* HandleKeyUp.
|
||||||
func (this *Hierarchy) HandleKeyUp (key input.Key, numberPad bool) {
|
func (this *Hierarchy) HandleKeyUp (key input.Key, numberPad bool) {
|
||||||
this.keyboardTargets(func (target anyBox) bool {
|
if this.anyFocused() {
|
||||||
if target.handleKeyUp(key, numberPad) {
|
this.keyboardTargets(func (target anyBox) bool {
|
||||||
return false
|
if target.handleKeyUp(key, numberPad) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if this.root != nil {
|
||||||
|
this.root.handleKeyUp(key, numberPad)
|
||||||
}
|
}
|
||||||
return true
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleMouseDown sends a mouse down event to the Boxes positioned underneath
|
// HandleMouseDown sends a mouse down event to the Boxes positioned underneath
|
||||||
|
Loading…
Reference in New Issue
Block a user