BAR
BAR

Reputation: 17111

Makie.jl detect mouse clicks on axis and plot area

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.

Upvotes: 0

Views: 142

Answers (1)

adigitoleo
adigitoleo

Reputation: 112

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

Upvotes: 0

Related Questions