diff --git a/NEWS.md b/NEWS.md index 25683a68b66..ee74c8bd739 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ ## master +- Fixed a bug where Axis still consumes scroll events when interactions are disabled [#3272](https://github.com/MakieOrg/Makie.jl/pull/3272) + ## v0.19.11 - Setup automatic colorbars for volumeslices [#3253](https://github.com/MakieOrg/Makie.jl/pull/3253). diff --git a/src/makielayout/blocks/axis.jl b/src/makielayout/blocks/axis.jl index 1e354ade703..71e117ef2eb 100644 --- a/src/makielayout/blocks/axis.jl +++ b/src/makielayout/blocks/axis.jl @@ -42,8 +42,8 @@ function register_events!(ax, scene) on(scene, evs.scroll) do s if is_mouseinside(scene) - scrollevents[] = ScrollEvent(s[1], s[2]) - return Consume(true) + result = setindex!(scrollevents, ScrollEvent(s[1], s[2])) + return Consume(result) end return Consume(false) end 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