Makie.jl detect mouse clicks on axis and plot area

47 views Asked by At

How can I detect clicks on either axis using Makie.jl?

I have tried:

is_mouseinside(ax.scene)

But that also triggers on clicks inside the plot area.

Also need to know how to detect clicks only in the plot area.

1

There are 1 answers

2
adigitoleo On

This is laid out in a few examples at https://docs.makie.org/stable/explanations/events/#mouse_interaction and the simplest example would be:

using GLMakie  # We need an interactive backend.

scene = Scene()
on(events(scene).mousebutton) do event
    if event.button == Mouse.left && event.action == Mouse.press  # Or Mouse.release, as you require.
        println("mouse click detected in plot area")
    end
end