diff --git a/test/events.jl b/test/events.jl index 31b2b484eb8..7a8491080ac 100644 --- a/test/events.jl +++ b/test/events.jl @@ -441,4 +441,47 @@ Base.:(==)(l::Or, r::Or) = l.left == r.left && l.right == r.right @test eventlog[7].px == Point2f(400, 400) empty!(eventlog) end + + # TODO: test more + @testset "Axis Interactions" begin + f = Figure(resolution = (400, 400)) + a = Axis(f[1, 1]) + e = events(f) + + names = (:rectanglezoom, :dragpan, :limitreset, :scrollzoom) + @test keys(a.interactions) == Set(names) + + types = (Makie.RectangleZoom, Makie.DragPan, Makie.LimitReset, Makie.ScrollZoom) + for (name, type) in zip(names, types) + @test a.interactions[name][1] == true + @test a.interactions[name][2] isa type + end + + blocked = Observable(true) + on(x -> blocked[] = false, e.scroll, priority = typemin(Int)) + + @assert !is_mouseinside(a.scene) + e.scroll[] = (0.0, 0.0) + @test !blocked[] + blocked[] = true + e.scroll[] = (0.0, 1.0) + @test !blocked[] + + blocked[] = true + e.mouseposition[] = (200, 200) + e.scroll[] = (0.0, 0.0) + @test blocked[] # TODO: should it block? + blocked[] = true + e.scroll[] = (0.0, 1.0) + @test blocked[] + + deactivate_interaction!.((a,), names) + + blocked[] = true + e.scroll[] = (0.0, 0.0) + @test !blocked[] + blocked[] = true + e.scroll[] = (0.0, 1.0) + @test !blocked[] + end end