|
|
@ -471,10 +471,22 @@ func (d *DropDown) openList(setFocus func(Primitive), app *Application) {
|
|
|
|
app.SetMouseCapture(func(event EventMouse) EventMouse {
|
|
|
|
app.SetMouseCapture(func(event EventMouse) EventMouse {
|
|
|
|
if d.open {
|
|
|
|
if d.open {
|
|
|
|
// Forward the mouse event to the list.
|
|
|
|
// Forward the mouse event to the list.
|
|
|
|
|
|
|
|
atX, atY := event.Position()
|
|
|
|
|
|
|
|
x, y, w, h := d.list.GetInnerRect()
|
|
|
|
|
|
|
|
if atX >= x && atY >= y && atX < x+w && atY < y+h {
|
|
|
|
|
|
|
|
// Mouse is within the list.
|
|
|
|
if handler := d.list.MouseHandler(); handler != nil {
|
|
|
|
if handler := d.list.MouseHandler(); handler != nil {
|
|
|
|
handler(event)
|
|
|
|
handler(event)
|
|
|
|
return EventMouse{} // handled
|
|
|
|
return EventMouse{} // handled
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Mouse not within the list.
|
|
|
|
|
|
|
|
if event.Buttons() != 0 {
|
|
|
|
|
|
|
|
// If a mouse button was pressed, cancel this capture.
|
|
|
|
|
|
|
|
app.SetMouseCapture(nil)
|
|
|
|
|
|
|
|
d.closeList(nil) // Close but don't focus.
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return event
|
|
|
|
return event
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -484,8 +496,10 @@ func (d *DropDown) openList(setFocus func(Primitive), app *Application) {
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DropDown) closeList(setFocus func(Primitive)) {
|
|
|
|
func (d *DropDown) closeList(setFocus func(Primitive)) {
|
|
|
|
d.open = false
|
|
|
|
d.open = false
|
|
|
|
|
|
|
|
if setFocus != nil {
|
|
|
|
setFocus(d)
|
|
|
|
setFocus(d)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Focus is called by the application when the primitive receives focus.
|
|
|
|
// Focus is called by the application when the primitive receives focus.
|
|
|
|
func (d *DropDown) Focus(delegate func(p Primitive)) {
|
|
|
|
func (d *DropDown) Focus(delegate func(p Primitive)) {
|
|
|
|