This example:
using Makie, Random
scene = Scene(resolution = (1200, 1500))
scene1 = Scene(scene, IRect(0, 0, 1200, 900))
image = rand(1:4, 640, 480)
imagenode = Node(image)
image!(scene1, imagenode, scale_plot = false, show_axis = false, interpolate = false, colormap=[:white, :blue, :green, :red])
scene2 = Scene(scene, IRect(0, 900, 1200, 550))
polynode = Node(rand(Vec2f, 10))
lines!(scene2, polynode)
scene3 = Scene(scene, IRect(0, 1460, 1200, 40))
textnode = Node("text")
text!(scene3, textnode, show_axis = false)
display(scene)
on(scene1.events.mousebuttons) do buttons
if ispressed(scene1, Mouse.left)
pos = to_world(scene1, Point2f0(scene1.events.mouseposition[]))
image[round.(Int, pos .+ 0.5)...] = 1
imagenode[] = image
polynode[] = rand(Vec2f, 10)
textnode[] = "$(round.(Int, pos .+ 0.5))"
end
end
# on(scene1.events.window_area) do _
# update!(scene1)
# end
restricts scene1.events.mousebuttons
to scene1
area until I zoom in. Then, clicks outside of visible scene1
may be passed to the callback. I tried to change it with the last (commented out) lines, but it doesn’t help. What is the way to restrict mouse click events to the visible subscene area when zooming and panning?