Add support for mouse hover events
This commit is contained in:
parent
19dbc73968
commit
e126c01055
6
event.go
6
event.go
@ -293,6 +293,7 @@ func (window *window) handleButtonRelease (
|
|||||||
window.updateModifiers(buttonEvent.State)
|
window.updateModifiers(buttonEvent.State)
|
||||||
window.updateMousePosition(buttonEvent.EventX, buttonEvent.EventY)
|
window.updateMousePosition(buttonEvent.EventX, buttonEvent.EventY)
|
||||||
dragging := window.drags[buttonEvent.Detail]
|
dragging := window.drags[buttonEvent.Detail]
|
||||||
|
window.drags[buttonEvent.Detail] = nil
|
||||||
|
|
||||||
if dragging != nil {
|
if dragging != nil {
|
||||||
dragging.handleMouseUp(input.Button(buttonEvent.Detail))
|
dragging.handleMouseUp(input.Button(buttonEvent.Detail))
|
||||||
@ -314,11 +315,14 @@ func (window *window) handleMotionNotify (
|
|||||||
for _, child := range window.drags {
|
for _, child := range window.drags {
|
||||||
if child == nil { continue }
|
if child == nil { continue }
|
||||||
child.handleMouseMove()
|
child.handleMouseMove()
|
||||||
|
window.hover(child)
|
||||||
handled = true
|
handled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !handled {
|
if !handled {
|
||||||
window.boxUnder(image.Pt(x, y)).handleMouseMove()
|
underneath := window.boxUnder(image.Pt(x, y))
|
||||||
|
underneath.handleMouseMove()
|
||||||
|
window.hover(underneath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
system.go
20
system.go
@ -56,8 +56,8 @@ type anyBox interface {
|
|||||||
// handleDndEnter ()
|
// handleDndEnter ()
|
||||||
// handleDndLeave ()
|
// handleDndLeave ()
|
||||||
// handleDndDrop (data.Data)
|
// handleDndDrop (data.Data)
|
||||||
// handleMouseEnter ()
|
handleMouseEnter ()
|
||||||
// handleMouseLeave ()
|
handleMouseLeave ()
|
||||||
handleMouseMove ()
|
handleMouseMove ()
|
||||||
handleMouseDown (input.Button)
|
handleMouseDown (input.Button)
|
||||||
handleMouseUp (input.Button)
|
handleMouseUp (input.Button)
|
||||||
@ -119,15 +119,31 @@ func (window *window) focus (box anyBox) {
|
|||||||
window.focused = box
|
window.focused = box
|
||||||
|
|
||||||
if previous != nil {
|
if previous != nil {
|
||||||
|
// FIXME why are we invalidating draw here
|
||||||
window.invalidateDraw(previous)
|
window.invalidateDraw(previous)
|
||||||
previous.handleFocusLeave()
|
previous.handleFocusLeave()
|
||||||
}
|
}
|
||||||
if box != nil && box.canBeFocused() {
|
if box != nil && box.canBeFocused() {
|
||||||
|
// FIXME why are we invalidating draw here
|
||||||
window.invalidateDraw(box)
|
window.invalidateDraw(box)
|
||||||
box.handleFocusEnter()
|
box.handleFocusEnter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (window *window) hover (box anyBox) {
|
||||||
|
if window.hovered == box { return }
|
||||||
|
|
||||||
|
previous := window.hovered
|
||||||
|
window.hovered = box
|
||||||
|
|
||||||
|
if previous != nil {
|
||||||
|
previous.handleMouseLeave()
|
||||||
|
}
|
||||||
|
if box != nil {
|
||||||
|
box.handleMouseEnter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (window *window) anyFocused () bool {
|
func (window *window) anyFocused () bool {
|
||||||
return window.focused != nil
|
return window.focused != nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user