roblillack / spot

React-like desktop GUI toolkit for Go
MIT License
1.11k stars 17 forks source link

Add support for `ListBox` component #2

Closed roblillack closed 5 months ago

roblillack commented 5 months ago

Basic ListBox support. Currently only implemented for FLTK, as gocoa does not support NSTable yet.

Example:

val, setVal := spot.SetState[int](0);

…

&ui.ListBox{
    X: 50, Y: 50, Width: 100, Height: 50,
    Values:    []string{"Null", "Eins", "Zwei", "Drei", "Vier", "Fünf", "Sechs", "Sieben", "Acht", "Neun"},
    Selection: []int{val},
    OnSelect: func(s []int) {
        if len(s) > 0 {
            setVal(s[0])
        }
    },
}

Looks roughly like this:

image image