Makie - mouseposition with respect to image plot

I am attempting to get the x, y position of a mouse click with respect to a plotted image. The code shown below is working except for a white border around the image. The returned x, y values include this border and the border changes as I resize the window. I have attempted to use padding = (0.0, 0.0) with no effect.

Any tips on how I could eliminate the border or get the x, y coordinates with respect to just the plot area?

using Makie
using Colors

scene = Scene(show_axis=false, resolution = (500, 500), padding = (0.0, 0.0))
image!(scene, rand(RGB{Float64}, (500,500)), interpolate=false, padding = (0.0, 0.0))


on( do button
    if ispressed(button, Mouse.left)
        println("Click ",[], scene.px_area[].widths)

Try the campixel! camera:

using Makie
using Colors

scene = Scene(camera=campixel!, raw=true, resolution = (500, 500))
image!(scene, rand(RGB{Float64}, (500,500)))

Does anyone have an update on how to do this in 2022?

1 Like