Consider the following code
using GLMakie
fig = Figure()
b = Button(fig, label="Select ABC", textsize=20)
m = Menu(fig, options=zip(["A", "AB", "ABC"], 1:3), default="A", textsize=20)
panel = GridLayout()
panel[:v] = [b, m]
fig[1,1] = panel
on(b.clicks) do n
# It seems you can pass any value to m.selection
m.selection[] = "ABC"
end
on(m.selection) do idx
println(idx) # it will print "ABC" when the button clicks
end
When the button is clicked, the listener of m.selection
is triggered. However, the Menu
object displayed in the figure still shows that the item “A” is selected but not “ABC”.
My question is: what can I do to let the menu selected item reflect the button click? Thanks!