diff --git a/ui/context.go b/ui/context.go index 3792ce6..1d916fe 100644 --- a/ui/context.go +++ b/ui/context.go @@ -8,6 +8,7 @@ type Context interface { Animate() Fonts() *Fonts HasQuit() bool + KeyModifiers() KeyModifier MousePosition() geom.PointF32 Overlays() *Overlays Quit() @@ -22,16 +23,17 @@ var _ Context = &context{} var _ EventTarget = &context{} type context struct { - animate bool - quit chan struct{} - renderer Renderer - view Control - mouse geom.PointF32 - tooltip *Tooltip - overlays *Overlays - fonts *Fonts - textures *Textures - style *Style + animate bool + quit chan struct{} + renderer Renderer + view Control + modifiers KeyModifier + mouse geom.PointF32 + tooltip *Tooltip + overlays *Overlays + fonts *Fonts + textures *Textures + style *Style } func newContext(r Renderer, s *Style, view Control) *context { @@ -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) Overlays() *Overlays { return c.overlays } @@ -97,6 +101,10 @@ func (c *context) Handle(e Event) { return case *MouseMoveEvent: c.mouse = e.Pos() + case *KeyDownEvent: + c.modifiers = e.Modifiers + case *KeyUpEvent: + c.modifiers = e.Modifiers } c.overlays.Handle(c, e) }