How to place a menu in GLMakie?

I have the following code:

using GLMakie

const running    = Observable(false)
fig = Figure(size=(400, 400), backgroundcolor=RGBf(0.7, 0.8, 1))
sub_fig = fig[1,1]
fig[2, 1] = buttongrid = GridLayout(tellwidth=true)
btn_PLAY_PAUSE  = Button(sub_fig, label = @lift($running ? "PAUSE" : " RUN "))
btn_STOP = Button(sub_fig, label="STOP")
buttongrid[1, 1:2] = [btn_PLAY_PAUSE, btn_STOP]

menu1 = Menu(fig[1,1], options = ["plot", "save as jld2", "save as pdf"], default = "plot")
menu1.width[]=100
menu1.halign[]=:left
menu1.valign[]=:top
fig

How can I place the menu at the top left side of the window with a small, well defined distance to the window border?

Does it work the same as legends? Legend · Makie

Give the menu alignmode=Outside(padding)

using GLMakie

const running    = Observable(false)
fig = Figure(size=(400, 400), backgroundcolor=RGBf(0.7, 0.8, 1))
sub_fig = fig[1,1]
fig[2, 1] = buttongrid = GridLayout(tellwidth=true)
btn_PLAY_PAUSE  = Button(sub_fig, label = @lift($running ? "PAUSE" : " RUN "))
btn_STOP = Button(sub_fig, label="STOP")
buttongrid[1, 1:2] = [btn_PLAY_PAUSE, btn_STOP]

menu1 = Menu(fig, options = ["plot", "save as jld2", "save as pdf"], default = "plot")
menu1.width[]=100
menu1.halign[]=:left
menu1.valign[]=:top
menu1.alignmode[]=Outside(10)
fig

Padding works fine now, but the menu is not yet at the top…

Because you changed your code, now it’s just Menu(fig, which will put the menu in the default 100x100 square as bbox. You can either choose a layout cell or do bbox = fig.scene.viewport

This works:

using GLMakie

const running    = Observable(false)
fig = Figure(size=(400, 400), backgroundcolor=RGBf(0.7, 0.8, 1))
sub_fig = fig[1,1]
fig[2, 1] = buttongrid = GridLayout(tellwidth=true)
btn_PLAY_PAUSE  = Button(sub_fig, label = @lift($running ? "PAUSE" : " RUN "))
btn_STOP = Button(sub_fig, label="STOP")
buttongrid[1, 1:2] = [btn_PLAY_PAUSE, btn_STOP]

menu1 = Menu(fig, bbox = fig.scene.viewport, options = ["plot", "save as jld2", "save as pdf"], default = "plot")
menu1.width[]=100
menu1.halign[]=:left
menu1.valign[]=:top
menu1.alignmode[]=Outside(10)
fig

Thank you!

But, to be honest, the documentation does not really mention this.

It’s hard to mention every possible combination of things you can do in Makie :slight_smile: the bbox thing is definitely mentioned in a couple places, and the viewport rectangle too, this is just a combination of the two, you could use any other rectangle observable

I created an issue: Help insufficient · Issue #3730 · MakieOrg/Makie.jl · GitHub