# How to get the reference to a text object in GLMakie

**URL:** <https://discourse.julialang.org/t/how-to-get-the-reference-to-a-text-object-in-glmakie/121555>\
**Category:** New to Julia\
**Tags:** glmakie\
**Created:** [October 21, 2024, 8:33pm UTC](https://discourse.julialang.org/t/how-to-get-the-reference-to-a-text-object-in-glmakie/121555 "2024-10-21T20:33:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![heinfleuren](https://avatars.discourse-cdn.com/v4/letter/h/e480ec/32.png) [@heinfleuren](https://discourse.julialang.org/u/heinfleuren)\
**Post date:** [October 21, 2024, 8:33pm UTC](https://discourse.julialang.org/t/how-to-get-the-reference-to-a-text-object-in-glmakie/121555/1 "2024-10-21T20:33:39Z")

</div>

I’m working on an application where you see locations in a map. Each location has a particular name created with the text! function. I now want to click in the ‘geo space’ on the text and with pick I want to get the reference to the text object. It comes close and things like mouseposition etc work. Also the idx works whether I click on the first or the third character. But I would love to see that the ptxt (from pick) is the same as the originally created text! object. What am I doing wrong? Or are there easier ways to do this?

```julia
using GLMakie

function start_mouse(ax, bx, vtxt)
    on(events(ax).mousebutton) do e
        ptxt, idx = pick(ax, events(ax).mouseposition[])
        if (is_mouseinside(ax))
            mp = events(ax).mouseposition[]
            bx.text = string(mp[1]) * " " * string(mp[2]) * 
                     "\n" * string(idx) * 
                     "\n" * string(ptxt) * 
                     "\n" * string(vtxt)
            
        end
    end
end

fig = Figure()
ax = Axis(fig[1,1])
bx = Label(fig[2,1])
bx.text = "Start"
bx.tellwidth = false
v_text = text!(ax, 5.0, 5.0, text="Hello")

start_mouse(ax, bx, v_text)

fig

```
