Added mouse enter/leave event.
This commit is contained in:
parent
e867925de8
commit
a6bb05794f
@ -112,12 +112,19 @@ type MouseButtonUpEvent struct {
|
|||||||
Pressure float32
|
Pressure float32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MouseEnterEvent struct {
|
||||||
|
MouseEvent
|
||||||
|
}
|
||||||
|
|
||||||
type MouseEvent struct {
|
type MouseEvent struct {
|
||||||
EventBase
|
EventBase
|
||||||
X, Y int
|
X, Y int
|
||||||
Z, W int
|
Z, W int
|
||||||
Display *Display
|
Display *Display
|
||||||
}
|
}
|
||||||
|
type MouseLeaveEvent struct {
|
||||||
|
MouseEvent
|
||||||
|
}
|
||||||
|
|
||||||
type MouseMoveEvent struct {
|
type MouseMoveEvent struct {
|
||||||
MouseEvent
|
MouseEvent
|
||||||
@ -181,9 +188,15 @@ func (eq *EventQueue) mapEvent(e *C.ALLEGRO_EVENT) Event {
|
|||||||
case C.ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
|
case C.ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
|
||||||
mouse := (*C.ALLEGRO_MOUSE_EVENT)(unsafe.Pointer(e))
|
mouse := (*C.ALLEGRO_MOUSE_EVENT)(unsafe.Pointer(e))
|
||||||
return &MouseButtonDownEvent{MouseEvent{eb, int(mouse.x), int(mouse.y), int(mouse.z), int(mouse.w), nil}, MouseButton(mouse.button), float32(mouse.pressure)}
|
return &MouseButtonDownEvent{MouseEvent{eb, int(mouse.x), int(mouse.y), int(mouse.z), int(mouse.w), nil}, MouseButton(mouse.button), float32(mouse.pressure)}
|
||||||
|
case C.ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY:
|
||||||
|
mouse := (*C.ALLEGRO_MOUSE_EVENT)(unsafe.Pointer(e))
|
||||||
|
return &MouseEnterEvent{MouseEvent{eb, int(mouse.x), int(mouse.y), int(mouse.z), int(mouse.w), nil}}
|
||||||
case C.ALLEGRO_EVENT_MOUSE_BUTTON_UP:
|
case C.ALLEGRO_EVENT_MOUSE_BUTTON_UP:
|
||||||
mouse := (*C.ALLEGRO_MOUSE_EVENT)(unsafe.Pointer(e))
|
mouse := (*C.ALLEGRO_MOUSE_EVENT)(unsafe.Pointer(e))
|
||||||
return &MouseButtonUpEvent{MouseEvent{eb, int(mouse.x), int(mouse.y), int(mouse.z), int(mouse.w), nil}, MouseButton(mouse.button), float32(mouse.pressure)}
|
return &MouseButtonUpEvent{MouseEvent{eb, int(mouse.x), int(mouse.y), int(mouse.z), int(mouse.w), nil}, MouseButton(mouse.button), float32(mouse.pressure)}
|
||||||
|
case C.ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY:
|
||||||
|
mouse := (*C.ALLEGRO_MOUSE_EVENT)(unsafe.Pointer(e))
|
||||||
|
return &MouseLeaveEvent{MouseEvent{eb, int(mouse.x), int(mouse.y), int(mouse.z), int(mouse.w), nil}}
|
||||||
case C.ALLEGRO_EVENT_KEY_DOWN:
|
case C.ALLEGRO_EVENT_KEY_DOWN:
|
||||||
key := (*C.ALLEGRO_KEYBOARD_EVENT)(unsafe.Pointer(e))
|
key := (*C.ALLEGRO_KEYBOARD_EVENT)(unsafe.Pointer(e))
|
||||||
return &KeyDownEvent{KeyEvent{eb, Key(key.keycode), nil}}
|
return &KeyDownEvent{KeyEvent{eb, Key(key.keycode), nil}}
|
||||||
|
@ -66,6 +66,10 @@ func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) {
|
|||||||
t.Handle(&ui.MouseButtonDownEvent{MouseEvent: mouseEvent(e.MouseEvent), Button: ui.MouseButton(e.Button)})
|
t.Handle(&ui.MouseButtonDownEvent{MouseEvent: mouseEvent(e.MouseEvent), Button: ui.MouseButton(e.Button)})
|
||||||
case *allg5.MouseButtonUpEvent:
|
case *allg5.MouseButtonUpEvent:
|
||||||
t.Handle(&ui.MouseButtonUpEvent{MouseEvent: mouseEvent(e.MouseEvent), Button: ui.MouseButton(e.Button)})
|
t.Handle(&ui.MouseButtonUpEvent{MouseEvent: mouseEvent(e.MouseEvent), Button: ui.MouseButton(e.Button)})
|
||||||
|
case *allg5.MouseEnterEvent:
|
||||||
|
t.Handle(&ui.MouseLeaveEvent{MouseEvent: mouseEvent(e.MouseEvent)})
|
||||||
|
case *allg5.MouseLeaveEvent:
|
||||||
|
t.Handle(&ui.MouseLeaveEvent{MouseEvent: mouseEvent(e.MouseEvent)})
|
||||||
case *allg5.MouseMoveEvent:
|
case *allg5.MouseMoveEvent:
|
||||||
t.Handle(&ui.MouseMoveEvent{MouseEvent: mouseEvent(e.MouseEvent), MouseWheel: float32(e.DeltaZ)})
|
t.Handle(&ui.MouseMoveEvent{MouseEvent: mouseEvent(e.MouseEvent), MouseWheel: float32(e.DeltaZ)})
|
||||||
case *allg5.UserEvent:
|
case *allg5.UserEvent:
|
||||||
|
@ -76,6 +76,8 @@ func (c *ControlBase) Handle(ctx Context, e Event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case *MouseLeaveEvent:
|
||||||
|
c.over = false
|
||||||
case *MouseButtonDownEvent:
|
case *MouseButtonDownEvent:
|
||||||
c.over = over(e.MouseEvent)
|
c.over = over(e.MouseEvent)
|
||||||
if c.over && e.Button == MouseButtonLeft {
|
if c.over && e.Button == MouseButtonLeft {
|
||||||
|
@ -72,6 +72,10 @@ type MouseButtonUpEvent struct {
|
|||||||
Button MouseButton
|
Button MouseButton
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MouseEnterEvent struct {
|
||||||
|
MouseEvent
|
||||||
|
}
|
||||||
|
|
||||||
type MouseEvent struct {
|
type MouseEvent struct {
|
||||||
EventBase
|
EventBase
|
||||||
X, Y float32
|
X, Y float32
|
||||||
@ -81,6 +85,10 @@ func (e *MouseEvent) Pos() geom.PointF32 {
|
|||||||
return geom.PtF32(e.X, e.Y)
|
return geom.PtF32(e.X, e.Y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MouseLeaveEvent struct {
|
||||||
|
MouseEvent
|
||||||
|
}
|
||||||
|
|
||||||
type MouseMoveEvent struct {
|
type MouseMoveEvent struct {
|
||||||
MouseEvent
|
MouseEvent
|
||||||
MouseWheel float32
|
MouseWheel float32
|
||||||
|
Loading…
Reference in New Issue
Block a user