Split NewListbox() into NewListbox() (single-selection) and NewMultiSelListbox() (multiple selection); fixed the documentaiton for the Listbox constructor(s) to talk about Listbox and not Combobox, and added some TODOs.
This commit is contained in:
parent
a6188ec490
commit
1e338afc4a
13
listbox.go
13
listbox.go
|
@ -17,8 +17,7 @@ type Listbox struct {
|
|||
initItems []string
|
||||
}
|
||||
|
||||
// NewCombobox makes a new combobox with the given items. If multiple is true, the listbox allows multiple selection.
|
||||
func NewListbox(multiple bool, items ...string) (l *Listbox) {
|
||||
func newListbox(multiple bool, items ...string) (l *Listbox) {
|
||||
l = &Listbox{
|
||||
sysData: mksysdata(c_listbox),
|
||||
initItems: items,
|
||||
|
@ -27,6 +26,16 @@ func NewListbox(multiple bool, items ...string) (l *Listbox) {
|
|||
return l
|
||||
}
|
||||
|
||||
// NewListbox creates a new single-selection Listbox with the given items loaded initially.
|
||||
func NewListbox(items ...string) *Listbox {
|
||||
return newListbox(false, items...)
|
||||
}
|
||||
|
||||
// NewMultiSelListbox creates a new multiple-selection Listbox with the given items loaded initially.
|
||||
func NewMultiSelListbox(items ...string) *Listbox {
|
||||
return newListbox(true, items...)
|
||||
}
|
||||
|
||||
// Append adds items to the end of the Listbox's list.
|
||||
// Append will panic if something goes wrong on platforms that do not abort themselves.
|
||||
func (l *Listbox) Append(what ...string) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
var prefsizetest = flag.Bool("prefsize", false, "")
|
||||
func listboxPreferredSizeTest() (*Window, error) {
|
||||
lb := NewListbox(false, "xxxxx", "y", "zzz")
|
||||
lb := NewListbox("xxxxx", "y", "zzz")
|
||||
g := NewGrid(1, lb)
|
||||
w := NewWindow("Listbox Preferred Size Test", 300, 300)
|
||||
return w, w.Open(g)
|
||||
|
@ -21,7 +21,7 @@ func gridWindow() (*Window, error) {
|
|||
b00 := NewButton("0,0")
|
||||
b01 := NewButton("0,1")
|
||||
b02 := NewButton("0,2")
|
||||
l11 := NewListbox(true, "1,1")
|
||||
l11 := NewMultiSelListbox("1,1")
|
||||
b12 := NewButton("1,2")
|
||||
l20 := NewLabel("2,0")
|
||||
c21 := NewCheckbox("2,1")
|
||||
|
@ -134,8 +134,8 @@ func myMain() {
|
|||
password := NewPasswordEdit()
|
||||
s0 := NewVerticalStack(s2, c, cb1, cb2, e, s3, pbar, sincdec, Space(), password)
|
||||
s0.SetStretchy(8)
|
||||
lb1 := NewListbox(true, "Select One", "Or More", "To Continue")
|
||||
lb2 := NewListbox(false, "Select", "Only", "One", "Please")
|
||||
lb1 := NewMultiSelListbox("Select One", "Or More", "To Continue")
|
||||
lb2 := NewListbox("Select", "Only", "One", "Please")
|
||||
i := 0
|
||||
doAdjustments := func() {
|
||||
cb1.Append("append")
|
||||
|
|
2
todo.md
2
todo.md
|
@ -10,7 +10,6 @@ so I don't forget:
|
|||
- [Windows, Mac OS X] should ListBox have a border style?
|
||||
- [Windows] a different border on LineEdits?
|
||||
- padding and spacing in Stack
|
||||
- change Listbox constructor so that there's a separate constructor for each variant, rather than passing in parameters
|
||||
- allow Combobox to have initial settings
|
||||
- Combobox and Listbox insertions and deletions should allow bulk (...string)
|
||||
- Combobox/Listbox.DeleteAll
|
||||
|
@ -74,6 +73,7 @@ super ultra important things:
|
|||
important things:
|
||||
- make specific wording in documentation consistent (make/create, etc.)
|
||||
- document minor details like wha thappens on specific events so that they are guaranteed to work the same on all platforms (are there any left?)
|
||||
- what happens when the user clicks and drags on a listbox
|
||||
- make passing of parameters and type conversions of parameters to uitask on Windows consistent: explicit _WPARAM(xxx)/_LPARAM(xxx)/uintptr(xxx), for example
|
||||
- do this for type signatures in exported functions: (err error) or just error?
|
||||
- do this for the names of GTK+ helper functions (gtkXXX or gXXX)
|
||||
|
|
Loading…
Reference in New Issue