Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combobox doesn't render on windows? #380

Open
markgician opened this issue Apr 21, 2020 · 4 comments
Open

combobox doesn't render on windows? #380

markgician opened this issue Apr 21, 2020 · 4 comments

Comments

@markgician
Copy link

Is it a known issue that combobox only render itself after mouse hoover over? This only happens in windows build, is there way to force to redraw the UI? Thanks!

@andlabs
Copy link
Owner

andlabs commented Apr 21, 2020

It is a known issue but I can't figure out on what configurations it happens... keep this open until further notice.

@kfsone
Copy link

kfsone commented Feb 26, 2021

This reproduces consistently for me: Go 1.16, Windows 10 x64:

https://gist.github.com/fbd4d52084621c49b5bf0b569b9195b4

	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)
	}

When you switch to Page 2, the combobox appears invisible until you mouse over it.

@kfsone
Copy link

kfsone commented Feb 26, 2021

After switching & mousing over, it remains rendered if you switch away & back or to a 3rd tab.

@kfsone
Copy link

kfsone commented Feb 26, 2021

Thinking it might be related, but there doesn't appear to be a way to prime a ComboBox with a selection:

  cbox := ui.NewComboBox()
  addEntries(cbox)
  cbox.OnSelected(func(_ *ui.Combobox) { panic("on selected") })
  parent.Append(cbox, false)
  cbox.SetSelected(0)
  win.Show()

edit: my bad, cbox.SetSelected never calls OnSelected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants