Skip to content

Instantly share code, notes, and snippets.

@kfsone
Created February 26, 2021 00:17
Show Gist options
  • Save kfsone/fbd4d52084621c49b5bf0b569b9195b4 to your computer and use it in GitHub Desktop.
Save kfsone/fbd4d52084621c49b5bf0b569b9195b4 to your computer and use it in GitHub Desktop.
andlabs/ui combobox not rendering in a tab on windows
package main
import (
"fmt"
"github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest"
)
func makePage1() ui.Control {
return ui.NewLabel("Page 1")
}
func makePage2() ui.Control {
vb := ui.NewVerticalBox()
vb.SetPadded(true)
vb.Append(ui.NewLabel("Choose"), false)
strings := make([]string, 300)
for i := 0; i < len(strings); i++ {
strings[i] = fmt.Sprintf("This is a string to choose %d", i)
}
cbox := ui.NewCombobox()
for _, entry := range strings {
cbox.Append(entry)
}
vb.Append(cbox, false)
return vb
}
func setupUI() {
win := ui.NewWindow("Test", 800, 600, true)
win.OnClosing(func(*ui.Window) bool {
ui.Quit()
return true
})
ui.OnShouldQuit(func() bool {
win.Destroy()
return true
})
tabCtrl := ui.NewTab()
win.SetChild(tabCtrl)
win.SetMargined(true)
tabCtrl.Append("Tab 1", makePage1())
tabCtrl.SetMargined(0, true)
tabCtrl.Append("Tab 2", makePage2())
tabCtrl.SetMargined(1, true)
win.Show()
}
func main() {
ui.Main(setupUI)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment