GLMakie: Change attributes in existing Screen objects

I would like to change line attributes inside an already displayed GLMakie screen object.
Below a simple example, unfortunately only the edge of the button changes.
Are there any ideas. The purpose is:
I would like to switch on and of line objects or change their color. Here my snippet:

using GLMakie
fig = Figure(resolution = (400, 400))
bt = Button(fig[1, 1]; label = "switch color", strokewidth = 4, tellheight = false, strokecolor = (:green))
ax = Axis(fig[2, 1]; title = "test", aspect=DataAspect(), tellheight = false)
l1 = lines!(ax, [1,2,3])
# ---
on(bt.clicks) do nclicks 
    if iseven(nclicks)
        bt.strokecolor = (:red)
        l1.attributes.attributes[:color] = (:red)
        ax.scene.plots[1].attributes.attributes[:color] = (:red)
    else
        bt.strokecolor = (:blue)
        l1.attributes.attributes[:color] = (:blue)
        ax.scene.plots[1].attributes.attributes[:color] = (:blue)
    end
end
# ---
resize_to_layout!(fig)
screen_obj = display(fig)
wait(screen_obj)

A simple li.color = :red should do it, the attributes and Axis stuff is unnecessary. What you’re doing I think is replacing the original color observables in the attribute dictionary by going into the internals like that.

Thanks for the suggestion!
Modify: ax.title = "new_text" is possible in side on() do [...] end
but l1.color = :colorname has no effect :frowning:
I am lucky!
l1.visible = false
has an effect, in my case this is sufficient for the moment :slight_smile:

using GLMakie
fig = Figure(resolution = (400, 400))
bt = Button(fig[1, 1]; label = "on/off", strokewidth = 4, tellheight = false, strokecolor = (:green))
ax = Axis(fig[2, 1]; title = "test", aspect=DataAspect(), tellheight = false)
l1 = lines!(ax, [1,2,3])
# ---
on(bt.clicks) do nclicks 
   if iseven(nclicks)
        l1.visible = true
        ax.title = "on"
        bt.label = "off"
    else
        l1.visible = false
        ax.title = "off"
        bt.label = "on"
    end
end
# ---
resize_to_layout!(fig)
scene_obj = display(fig)
wait(scene_obj)

This works: :slight_smile:

[...]
on(bt.clicks) do nclicks 
    l1.visible = false
    if iseven(nclicks)
        l1.color = :red
    else
        l1.color = :blue
    end
    l1.visible = true
end
[...]

Oh, can you open an issue here: new issue?
That sounds like a bug in the on demand renderloop not rendering a new frame, since there really should be no other reason why the color only updates after a visibility change…

It is really strange, I do not know why, today I tried to reproduce the error from yesterday,
but failed. Therefore, under some circumstances, it might be that the change of line attributes
fails and in this case switching visibility off/on might help.