From c624cc08cde423ec5abe30803f568d91417bdb60 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Fri, 19 Apr 2024 22:45:13 -0700 Subject: [PATCH] IsMouseEvent boolean on all current mouse events --- event/event.go | 5 +++-- sdl/events.go | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/event/event.go b/event/event.go index ddb7faa..ec5f761 100644 --- a/event/event.go +++ b/event/event.go @@ -27,8 +27,9 @@ type State struct { keydown map[string]interface{} // Cursor position - CursorX int - CursorY int + IsMouseEvent bool // A mouse event this tick + CursorX int + CursorY int // Window resized WindowResized bool diff --git a/sdl/events.go b/sdl/events.go index d75f474..0669af6 100644 --- a/sdl/events.go +++ b/sdl/events.go @@ -25,6 +25,7 @@ func (r *Renderer) Poll() (*event.State, error) { // Reset some events. s.WindowResized = false s.Touching = false + s.IsMouseEvent = false // helper function to push keyboard key names on keyDown events only. pushKey := func(name string, state uint8) { @@ -56,6 +57,7 @@ func (r *Renderer) Poll() (*event.State, error) { t.Timestamp, sdl.GetTicks(), t.Type, t.Which, t.X, t.Y, t.XRel, t.YRel, ) } + s.IsMouseEvent = true // Push the cursor position. s.CursorX = int(t.X) @@ -66,6 +68,7 @@ func (r *Renderer) Poll() (*event.State, error) { t.Timestamp, sdl.GetTicks(), t.Type, t.Which, t.X, t.Y, t.Button, t.State, ) } + s.IsMouseEvent = true // Push the cursor position. s.CursorX = int(t.X) @@ -108,6 +111,7 @@ func (r *Renderer) Poll() (*event.State, error) { t.Timestamp, sdl.GetTicks(), t.Type, t.Which, t.X, t.Y, ) } + s.IsMouseEvent = true case *sdl.TouchFingerEvent: if DebugTouchEvents { fmt.Printf("[%d ms] tick:%d TouchFinger type:%d Finger=%d TouchID=%+v Pressure=%f XY=%f,%f\n",