Skip to content

How to get current widget relative mouse pos on hover ? #615

Closed Answered by manuel-koch
manuel-koch asked this question in Q&A
Discussion options

You must be logged in to vote

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 ?

giu.Custom(func() {
    imageBorderSize := float32(1)
    cursorPt := giu.GetCursorScreenPos()
    giu.Layout{
	    giu.Image(texture).BorderCol(color.RGBA{R: 128, G: 128, B: 128, A: 255}).Size(width, height),
	    giu.Event().OnHover(func() {
		    relPt := giu.GetMousePos().Sub(cursorPt)
		    // need to account for image border !?
		    if relPt.X > 0 && relPt.Y > 0 && relPt.X < int(width+2*imageBorderSize) && relPt.Y < int(height+2*imageBor…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@manuel-koch
Comment options

@gucio321
Comment options

@manuel-koch
Comment options

Answer selected by gucio321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants