-
-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add logical expressions for ispressed
#1222
Conversation
Hm, I guess that's a nice idea! struct And
a::Keyboard.Button
b::Keyboard.Button
end
Base.:(&)(a::Keyboard.Button, b::Keyboard.Button) = And(a, b)
julia> Keyboard.left_alt & Keyboard.left_shift
And(Makie.Keyboard.left_alt, Makie.Keyboard.left_shift) |
I'm thinking about adding something like |
Changes:
|
Awesome! :) This is ready to go right? |
I did a quick merge to see if tests fail. I think the docs I wrote might be broken now that we moved to Franklin. I also had a couple of concerns that I didn't mention yet. I'm wondering if it would be good to have variants of Since When I thought about this last I decided that I didn't want to make this pr more complicated. Maybe it's better to leave this as is and make another pr later adding that stuff? |
Yeah, I think that's a good idea! |
Merged in #1393 |
Adds the possibility to pass logical expressions to
ispressed
, for examplewhere
hotkey
lowers toAnd(Keyboard.left_shift, And(Not(Keyboard.left_control), Mouse.left))
. So you could set up key combinations (a && b), alternative hotkeys (a || b) and everything in between. Performance is the same if not a bit better (BenchmarkTools is given me less frequent and lower max times for the case above).With these changes things like
https://github.com/JuliaPlots/Makie.jl/blob/194e767e207b8b67796412b1fe40fd7fd18f54c6/src/camera/camera3d.jl#L275
could be simplified to
if dragging[] && ispressed(scene, button[])
.I also added a
ispressed(scene, ::Bool)
so you can have a hotkey be always active (true) or always inactive (false). This would add a way to disable an interaction that relies onispressed
.