|
|
|
@ -9,8 +9,9 @@ import (
|
|
|
|
|
|
|
|
|
|
// DropDownOption is one option that can be selected in a drop-down primitive.
|
|
|
|
|
type DropDownOption struct {
|
|
|
|
|
text string // The text to be displayed in the drop-down.
|
|
|
|
|
selected func(index int, option *DropDownOption) // The (optional) callback for when this option was selected.
|
|
|
|
|
text string // The text to be displayed in the drop-down.
|
|
|
|
|
selected func(index int, option *DropDownOption) // The (optional) callback for when this option was selected.
|
|
|
|
|
reference interface{} // An optional reference object.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewDropDownOption(text string) *DropDownOption {
|
|
|
|
@ -34,6 +35,17 @@ func (d *DropDownOption) SetSelectedFunc(handler func(index int, option *DropDow
|
|
|
|
|
return d
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetReference returns the reference object of this dropdown option.
|
|
|
|
|
func (d *DropDownOption) GetReference() interface{} {
|
|
|
|
|
return d.reference
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetReference allows you to store a reference of any type in this option.
|
|
|
|
|
func (d *DropDownOption) SetReference(reference interface{}) *DropDownOption {
|
|
|
|
|
d.reference = reference
|
|
|
|
|
return d
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetChangedFunc sets a handler which is called when the user changes the
|
|
|
|
|
// drop-down's option. This handler will be called in addition and prior to
|
|
|
|
|
// an option's optional individual handler. The handler is provided with the
|
|
|
|
|