Makie mouse_in_scene gives pixel positions

Hi,

I don’t understand why the following code doesn’t work. (maybe I an just blind)



using AbstractPlotting
X = Node( rand(Point2f0, 10) )
fig = Figure(resolution = (1200, 900))
scatter(fig[1,1], X)


scene = fig.scene
mouse_btn = on(scene.events.mousebuttons, weak = true) do buttons
    if ispressed(scene, Mouse.left)
        p = Point2f0( AbstractPlotting.mouse_in_scene(scene)[] )
        X.val[1] = p
        X[] = X[]
        #println(p)
    end
end

fig
#println( AbstractPlotting.mouse_in_scene(fig.scene))

I would expect that a mouse click sets the first point of the array X to the position of the mouse click.
But on my computer, the Point p seems to be in pixel coordinates?


Relevant docs: https://makie.juliaplots.org/stable/abstractplotting_api.html#AbstractPlotting.mouse_in_scene-Tuple{SceneLike}

Env:

Julia Version 1.5.4
Commit 69fcb5745b (2021-03-11 19:13 UTC)       
Platform Info:
  OS: Windows (x86_64-w64-mingw32)

(mouse_interactive) pkg> st
Status `D:\workspace\julia_projects\mouse_interactive\Project.toml`
  [537997a7] AbstractPlotting v0.15.27
  [13f3f980] CairoMakie v0.3.19
  [e9467ef8] GLMakie v0.1.30
  [ee78f7c6] Makie v0.12.0

Ok, it seems that fig.scene is not the correct scene of the scatter plot.
If I create a scene with scene = Scene() and use mouseposition() then I get the world coordinates and it works.

Still, I don’t know how to get select the current scene.

Ok, I found the solution:


n = 10
X = Node( rand(Point2f0,n) )
fig = Figure( resolution=(500,500))
plt = scatter(fig[1,1], X)

scene = plt.axis.scene
mouse_btn = on(scene.events.mousebuttons, weak = true) do buttons
    if ispressed(scene, Mouse.left)
        p = mouseposition(scene)
        X.val[1] = p
        X[] = X[]
        println(p)
    end
end

fig