How to get current widget relative mouse pos on hover ? #615
-
I can attach an hover event handler to my widget, but how do I get the widget relative mouse position ? giu.Image(texture).Size(100, 100),
giu.Event().OnHover(func() {
// how to get image relative mouse position that triggered the hover event ?
}) |
Beta Was this translation helpful? Give feedback.
Answered by
manuel-koch
Nov 30, 2022
Replies: 1 comment 3 replies
-
math 😄 // save this somewhere before rendering your widget
x, y := giu.GetCursorPos()
// and in event handler:
mouse := giu.GetMousePos()
relativeposInsideWidget := mouse.Sub(image.Pt(x, y))
// do your stuff... |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following seems to work, but I have to substract (1,1) to get good relative points matching the actual image area. Is this maybe due to the border around the image ? How can image border be disabled - i.e. not just selecting transparent color ?