Skip to content

Commit

Permalink
Fix deactivated scroll interactions still consuming event (#3272)
Browse files Browse the repository at this point in the history
* propagate scroll consumes

* add tests for axis scroll events

* update NEWS

* simplify

---------

Co-authored-by: Simon <[email protected]>
  • Loading branch information
ffreyer and SimonDanisch authored Oct 5, 2023
1 parent 808a61d commit ce5c214
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions src/makielayout/blocks/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions test/events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ce5c214

Please sign in to comment.