Hierarchy is now responsible for focusing boxes when they are clicked
This commit is contained in:
parent
a92951f891
commit
180a5eb8d1
@ -336,13 +336,6 @@ func (this *box) handleMouseDown (button input.Button) (caught bool) {
|
|||||||
this.invalidateStyle()
|
this.invalidateStyle()
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.focusable {
|
|
||||||
this.SetFocused(true)
|
|
||||||
} else {
|
|
||||||
hierarchy := this.getHierarchy()
|
|
||||||
if hierarchy == nil { return }
|
|
||||||
hierarchy.focus(nil)
|
|
||||||
}
|
|
||||||
for _, listener := range this.on.buttonDown.Listeners() {
|
for _, listener := range this.on.buttonDown.Listeners() {
|
||||||
if listener(button) { caught = true }
|
if listener(button) { caught = true }
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,16 @@ func (this *Hierarchy) HandleKeyUp (key input.Key, numberPad bool) {
|
|||||||
// information, HandleMouseMove must be called *before* HandleMouseDown.
|
// information, HandleMouseMove must be called *before* HandleMouseDown.
|
||||||
func (this *Hierarchy) HandleMouseDown (button input.Button) {
|
func (this *Hierarchy) HandleMouseDown (button input.Button) {
|
||||||
boxes := []anyBox { }
|
boxes := []anyBox { }
|
||||||
|
first := true
|
||||||
this.boxesUnder(this.mousePosition)(func (box anyBox) bool {
|
this.boxesUnder(this.mousePosition)(func (box anyBox) bool {
|
||||||
|
if first {
|
||||||
|
if box.canBeFocused() {
|
||||||
|
this.focus(box)
|
||||||
|
} else {
|
||||||
|
this.focus(nil)
|
||||||
|
}
|
||||||
|
first = false
|
||||||
|
}
|
||||||
boxes = append(boxes, box)
|
boxes = append(boxes, box)
|
||||||
return !box.handleMouseDown(button)
|
return !box.handleMouseDown(button)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user