Exposed last known key modifiers in context.

This commit is contained in:
Sander Schobers 2020-05-18 20:35:34 +02:00
parent e7ada7fea0
commit 16d4e26cd0

View File

@ -8,6 +8,7 @@ type Context interface {
Animate() Animate()
Fonts() *Fonts Fonts() *Fonts
HasQuit() bool HasQuit() bool
KeyModifiers() KeyModifier
MousePosition() geom.PointF32 MousePosition() geom.PointF32
Overlays() *Overlays Overlays() *Overlays
Quit() Quit()
@ -26,6 +27,7 @@ type context struct {
quit chan struct{} quit chan struct{}
renderer Renderer renderer Renderer
view Control view Control
modifiers KeyModifier
mouse geom.PointF32 mouse geom.PointF32
tooltip *Tooltip tooltip *Tooltip
overlays *Overlays overlays *Overlays
@ -66,6 +68,8 @@ func (c *context) HasQuit() bool {
} }
} }
func (c *context) KeyModifiers() KeyModifier { return c.modifiers }
func (c *context) MousePosition() geom.PointF32 { return c.mouse } func (c *context) MousePosition() geom.PointF32 { return c.mouse }
func (c *context) Overlays() *Overlays { return c.overlays } func (c *context) Overlays() *Overlays { return c.overlays }
@ -97,6 +101,10 @@ func (c *context) Handle(e Event) {
return return
case *MouseMoveEvent: case *MouseMoveEvent:
c.mouse = e.Pos() c.mouse = e.Pos()
case *KeyDownEvent:
c.modifiers = e.Modifiers
case *KeyUpEvent:
c.modifiers = e.Modifiers
} }
c.overlays.Handle(c, e) c.overlays.Handle(c, e)
} }