Closed jonfriesen closed 6 months ago
You should use SingleWindowWithMenu
Using SingleWindowWithMenu works, eg the example below.
I'm a bit confused what the purpose of MainMenuBar
?
func loop() {
giu.SingleWindowWithMenuBar().Layout(
giu.MenuBar().Layout(
giu.Menu("File").Layout(
giu.MenuItem("Open Modal").OnClick(func() {
showModal = true
}),
giu.Separator(),
giu.MenuItem("Exit").OnClick(func() {
}),
),
),
// ... more layouts
)
}
@jonfriesen When you use multiple WindowWidget
s, then you use MainMenuBar. When you decide to use SingleWindowWidget
and you want menu bar, then you use SingleWindowWithMenubarWidget
and the MenuBarWidget
.
Thanks for the explanation! That makes sense!
also, here is an example:
package main
import "github.com/AllenDang/giu"
var singleWindow bool
func menubarLayout() giu.Widget {
return giu.Layout{
giu.Menu("File").Layout(
giu.MenuItem("Save"),
),
}
}
func loop() {
if singleWindow {
giu.SingleWindowWithMenuBar().Layout(
giu.MenuBar().Layout(menubarLayout()),
giu.Checkbox("Show single window", &singleWindow),
)
} else {
giu.MainMenuBar().Layout(
menubarLayout(),
).Build()
giu.Window("Window 1").Layout(
giu.Label("I am a window 1"),
)
giu.Window("Window 2").Layout(
giu.Label("I am a window 2"),
giu.Checkbox("Show single window", &singleWindow),
)
}
}
func main() {
wnd := giu.NewMasterWindow("Menubar usage", 640, 480, 0)
wnd.Run(loop)
}
What happend?
I'm running v0.7.0 on a M1 Mac. The menu bar should be showing up, but appears to be covered by the SingleWindow.
Code example
```golang package main import ( "github.com/AllenDang/giu" ) var ( showModal bool inputText string ) func loop() { giu.MainMenuBar().Layout( giu.Menu("File").Layout( giu.MenuItem("Open Modal").OnClick(func() { showModal = true }), giu.Separator(), giu.MenuItem("Exit").OnClick(func() { }), ), ).Build() giu.SingleWindow().Layout( giu.Custom(func() { if showModal { giu.OpenPopup("Modal Popup") } giu.PopupModal("Modal Popup").Layout( giu.Label("Enter some text"), giu.InputText(&inputText).Size(200), giu.Button("OK").OnClick(func() { giu.CloseCurrentPopup() showModal = false // You can add additional actions here after clicking OK }), ).Build() }), giu.Label("You entered: "+inputText), ) } func main() { wnd := giu.NewMasterWindow("Custom Modal Example", 400, 200, 0) wnd.Run(loop) } ```main.go
To Reproduce
Version
(latest)
OS
MacOS Sonoma 14.2.1 (23C71)