Disable hover effects when mouse leaves window.

This commit is contained in:
Sander Schobers 2020-05-11 08:03:33 +02:00
parent 6a7843f314
commit a72f416650
2 changed files with 9 additions and 0 deletions

View File

@ -39,6 +39,10 @@ func (b *ControlBase) Handle(ctx *Context, event sdl.Event) {
if b.IsMouseOver && e.Button == sdl.BUTTON_LEFT && e.Type == sdl.MOUSEBUTTONDOWN {
b.Invoke(ctx, b.OnLeftMouseButtonClick)
}
case *sdl.WindowEvent:
if e.Event == sdl.WINDOWEVENT_LEAVE {
b.IsMouseOver = false
}
}
}

View File

@ -91,6 +91,11 @@ func (r *terrainRenderer) Handle(ctx *Context, event sdl.Event) {
r.project.update(ctx.Renderer)
}
}
case *sdl.WindowEvent:
if e.Event == sdl.WINDOWEVENT_LEAVE {
r.hover = nil
r.project.update(ctx.Renderer)
}
}
}