# Makie.jl - how to change the cursor?

**URL:** <https://discourse.julialang.org/t/makie-jl-how-to-change-the-cursor/60380>\
**Category:** Visualization\
**Tags:** question, makie\
**Created:** [May 1, 2021, 1:43pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-change-the-cursor/60380 "2021-05-01T13:43:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [May 1, 2021, 1:43pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-change-the-cursor/60380/1 "2021-05-01T13:43:37Z")

</div>

How can I change the cursor to a sand clock to indicate the user to wait with MakieGL?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [May 1, 2021, 2:46pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-change-the-cursor/60380/2 "2021-05-01T14:46:14Z")

</div>

Makie currently doesn’t specifically expose this feature, but GLFW itself can change the window cursor. You can try to grab the underlying glfw window and directly change it.

[https://www.glfw.org/docs/3.2/input\_guide.html#cursor\_custom](https://www.glfw.org/docs/3.2/input_guide.html#cursor_custom)

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [May 1, 2021, 4:20pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-change-the-cursor/60380/3 "2021-05-01T16:20:17Z")

</div>

You get the underlying window with:  
screen = display(scene)  
glfw\_window = GLMakie.to\_native(screen)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [May 1, 2021, 4:45pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-change-the-cursor/60380/4 "2021-05-01T16:45:20Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Post date:** [December 1, 2021, 12:41am UTC](https://discourse.julialang.org/t/makie-jl-how-to-change-the-cursor/60380/5 "2021-12-01T00:41:42Z")

</div>

Here is a complete example

```julia
using GLMakie
using Makie
using GLMakie: GLFW
using Makie.ColorTypes: RGBA, N0f8
# TODO do not leak memory
cursor1 = GLFW.CreateStandardCursor(GLFW.CROSSHAIR_CURSOR)

img = fill(RGBA{N0f8}(0,0,0,0), 15, 15)
img[8, :] .= RGBA(1.0, 0.0, 1.0, 1.0)
img[:, 8] .= RGBA(1.0, 0.0, 1.0, 1.0)
# img[1, 1] is upper left
# img[1, end] is upper right

img_ = collect(reinterpret(NTuple{4, UInt8}, img))
hotspot = (8, 8)
cursor2 = ccall((:glfwCreateCursor, GLFW.libglfw), GLFW.Cursor, (Ref{GLFW.GLFWImage}, Cint, Cint), img_, hotspot[1], hotspot[2])

fig = Figure()
ax = Axis(fig[1, 1], title = "Demo")
ax.autolimitaspect = 1.0
scatter!(ax, [(-5, -5), (5, 5)])
screen = display(fig)
window = GLMakie.to_native(screen)

cursor_Fdata_obs = lift(events(fig).mouseposition) do mp
    # `mp` is relative to the window, throw it away.
    return mouseposition(ax.scene)
end

on(cursor_Fdata_obs) do cursor_Fdata
    cursor_Fraster = Tuple(round.(Int, cursor_Fdata))
    if iseven(sum(cursor_Fraster)) # checkboard pattern
        GLFW.SetCursor(window, cursor1)
    else
        GLFW.SetCursor(window, cursor2)
    end
end

```

The transition between cursors seems jumpy. There is also some visual ringing. None of these issues show up in the screen recording I made, though!  
 ![output](https://global.discourse-cdn.com/julialang/original/3X/c/5/c59f5ca3108616e955f73f8acac9a55efa5b7045.gif)

What you can see is that there is some scaling issue. The purple cross hair is not actually 1 pixel wide. This is probably some issue with the High DPI / Retina display scaling. Also, if I try to take a screenshot, the cursor appears in the wrong position (outside the Makie window).

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [December 1, 2021, 9:59am UTC](https://discourse.julialang.org/t/makie-jl-how-to-change-the-cursor/60380/6 "2021-12-01T09:59:23Z")

</div>

Hm, that sounds like an issue for [https://github.com/glfw/glfw](https://github.com/glfw/glfw)
