diff --git a/allg5ui/renderer.go b/allg5ui/renderer.go index 0c2e71f..311048b 100644 --- a/allg5ui/renderer.go +++ b/allg5ui/renderer.go @@ -66,12 +66,12 @@ type Renderer struct { // Renderer implementation (events) -func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) { +func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) bool { r.disp.Flip() var ev = eventWait(r.eq, wait) if ev == nil { - return + return false } cursor := r.cursor @@ -141,6 +141,7 @@ func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) { r.disp.SetMouseCursor(allg5.MouseCursorEdit) } } + return true } func (r *Renderer) RegisterRecorder(rec *allg5.Recorder) { diff --git a/sdlui/renderer.go b/sdlui/renderer.go index 45c385f..9242502 100644 --- a/sdlui/renderer.go +++ b/sdlui/renderer.go @@ -100,7 +100,7 @@ func (r *Renderer) WindowBounds() geom.RectangleF32 { return geom.RectF32(float32(x), float32(y), float32(x+w), float32(y+h)) } -func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) { +func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) bool { r.renderer.Present() waitOrPoll := func() sdl.Event { @@ -111,7 +111,9 @@ func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) { } cursor := r.cursor + var pushed bool for event := waitOrPoll(); event != nil; event = sdl.PollEvent() { + pushed = true r.cursor = ui.MouseCursorDefault var unhandled bool @@ -191,6 +193,7 @@ func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) { sdl.SetCursor(r.SystemCursor(sdl.SYSTEM_CURSOR_IBEAM)) } } + return pushed } func (r *Renderer) Refresh() { diff --git a/ui/renderer.go b/ui/renderer.go index 31c4547..85a2488 100644 --- a/ui/renderer.go +++ b/ui/renderer.go @@ -9,7 +9,7 @@ import ( type Renderer interface { // Events - PushEvents(t EventTarget, wait bool) + PushEvents(t EventTarget, wait bool) bool Refresh() // Lifetime diff --git a/ui/ui.go b/ui/ui.go index 134c0ec..737fcfd 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -55,9 +55,12 @@ func RunWait(r Renderer, s *Style, view Control, wait bool) error { tooltip := ctx.tooltip.Text ctx.tooltip.Text = "" - r.PushEvents(ctx, wait) - if ctx.tooltip.Text != tooltip { - ctx.overlays.SetVisibility(uiDefaultTooltipOverlay, ctx.tooltip.Text != "") + if r.PushEvents(ctx, wait) { + if ctx.tooltip.Text != tooltip { + ctx.overlays.SetVisibility(uiDefaultTooltipOverlay, ctx.tooltip.Text != "") + } + } else { + ctx.tooltip.Text = tooltip } } return nil