Forward Mouse input to Makie
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start by reading the referenced GtkMakie.jl src/events.jl implementation and the MouseArea workaround in this issue, then inspect how QML.jl exposes the Makie viewport and scene.events callbacks. Done means mouse and keyboard input reaches Makie reliably, including movement, buttons, wheel events, and coordinates, so interactions such as spinning 3D plots work without the workaround.
Written by the indexing model from the issue text.
Description
It would be useful to forward mouse (and keyboard) input to Makie. E.g. to be able to spin 3d plots using the mouse.
The proper way to do this would probably to adapt the code at https://github.com/jwahlstrand/GtkMakie.jl/blob/main/src/events.jl
At the moment, I have a workaround, by putting a MouseArea over the Makie viewport.
Here's an example of how it can be done, it might be useful to someone in the meantime. 🙂
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.AllButtons
onPressed: mouse=>Julia.mouse_press_callback(mouse.x,height-mouse.y-1,mouse.button)
onReleased: mouse=>Julia.mouse_release_callback(mouse.x,height-mouse.y-1,mouse.button)
onPositionChanged: mouse=>Julia.mouse_position_callback(mouse.x,height-mouse.y-1)
onWheel: wheel=>Julia.mouse_wheel_callback(wheel.x, wheel.y, wheel.angleDelta.x, wheel.angleDelta.y)
}
and in the callbacks we update the Observables in scene.events:
function mouse_button_qt2makie(button)
button == 1 && return Makie.Mouse.left
button == 2 && return Makie.Mouse.right
button == 4 && return Makie.Mouse.middle
Makie.Mouse.none
end
function mouse_press_callback(mouseX, mouseY, button)
scene.events.mouseposition[] = (mouseX,mouseY)
b = mouse_button_qt2makie(button)
if b != Makie.Mouse.none
scene.events.mousebutton[] = Makie.MouseButtonEvent(b, Makie.Mouse.press)
end
end
function mouse_release_callback(mouseX, mouseY, button)
scene.events.mouseposition[] = (mouseX,mouseY)
b = mouse_button_qt2makie(button)
if b != Makie.Mouse.none
scene.events.mousebutton[] = Makie.MouseButtonEvent(b, Makie.Mouse.release)
end
end
function mouse_position_callback(mouseX, mouseY)
scene.events.mouseposition[] = (mouseX,mouseY)
end
function mouse_wheel_callback(mouseX, mouseY, angleDeltaX, angleDeltaY)
scene.events.mouseposition[] = (mouseX,mouseY)
scene.events.scroll[] = (angleDeltaX/120,angleDeltaY/120)
end
- Dominant language
- Julia
- Stars
- 437
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaGraphics/QML.jl
-
documentation
Difficulty 4/5 3-5 days Newbie friendliness 38/100
JuliaGraphics/QML.jl#229 · 1 reaction ·
-
workaround available
Difficulty 4/5 3-5 days Newbie friendliness 25/100
JuliaGraphics/QML.jl#217 · 2 comments ·
-
makie package compiler
Difficulty 5/5 Over a week Newbie friendliness 25/100
JuliaGraphics/QML.jl#206 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
JuliaGraphics/QML.jl#205 · 3 comments ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
JuliaGraphics/QML.jl#195 · 3 comments ·
All issues in JuliaGraphics/QML.jl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Add project: Typst_jll.jlPossibly taken @github-actions claimed this today. Openadd-project
Difficulty 1/5 Under an hour Newbie friendliness 76/100
YDX-2147483647/best-of-typst#590 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100