Exposed last known key modifiers in context.
This commit is contained in:
parent
e7ada7fea0
commit
16d4e26cd0
@ -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()
|
||||||
@ -22,16 +23,17 @@ var _ Context = &context{}
|
|||||||
var _ EventTarget = &context{}
|
var _ EventTarget = &context{}
|
||||||
|
|
||||||
type context struct {
|
type context struct {
|
||||||
animate bool
|
animate bool
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
renderer Renderer
|
renderer Renderer
|
||||||
view Control
|
view Control
|
||||||
mouse geom.PointF32
|
modifiers KeyModifier
|
||||||
tooltip *Tooltip
|
mouse geom.PointF32
|
||||||
overlays *Overlays
|
tooltip *Tooltip
|
||||||
fonts *Fonts
|
overlays *Overlays
|
||||||
textures *Textures
|
fonts *Fonts
|
||||||
style *Style
|
textures *Textures
|
||||||
|
style *Style
|
||||||
}
|
}
|
||||||
|
|
||||||
func newContext(r Renderer, s *Style, view Control) *context {
|
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) 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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user