2022-10-20 06:55:42 -05:00
|
|
|
package gui
|
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
// functions to create 'Dropdown' and 'Combobox'
|
|
|
|
// Combobox is a Dropdown you can edit
|
|
|
|
// Thererfore, AddDropdownName() is used on both combobox and dropdown nodes
|
|
|
|
// since it is the same. confusing names? maybe...
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
import (
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
)
|
|
|
|
|
|
|
|
// add a new entry to the dropdown name
|
2022-11-13 08:53:03 -06:00
|
|
|
func (n *Node) AddDropdownName(name string) {
|
2023-03-23 12:35:12 -05:00
|
|
|
n.AddText(name)
|
2022-10-20 06:55:42 -05:00
|
|
|
}
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
// Set the dropdown menu to 'name'
|
|
|
|
func (n *Node) SetDropdownName(name string) {
|
2023-03-03 14:41:38 -06:00
|
|
|
n.SetText(name)
|
2023-02-25 14:05:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (n *Node) NewDropdown(name string) *Node {
|
2023-03-01 11:35:36 -06:00
|
|
|
newNode := n.New(name, toolkit.Dropdown, nil)
|
2023-03-23 12:35:12 -05:00
|
|
|
|
|
|
|
var a toolkit.Action
|
2023-03-29 23:03:04 -05:00
|
|
|
a.ActionType = toolkit.Add
|
2023-03-23 12:35:12 -05:00
|
|
|
// a.Widget = &newNode.widget
|
|
|
|
// a.Where = &n.widget
|
|
|
|
// action(&a)
|
|
|
|
newaction(&a, newNode, n)
|
|
|
|
|
2023-03-03 14:41:38 -06:00
|
|
|
return newNode
|
|
|
|
}
|
2022-10-20 06:55:42 -05:00
|
|
|
|
2023-03-03 14:41:38 -06:00
|
|
|
func (n *Node) NewCombobox(name string) *Node {
|
|
|
|
newNode := n.New(name, toolkit.Combobox, nil)
|
2023-03-23 12:35:12 -05:00
|
|
|
|
|
|
|
var a toolkit.Action
|
2023-03-29 23:03:04 -05:00
|
|
|
a.ActionType = toolkit.Add
|
2023-03-23 12:35:12 -05:00
|
|
|
// a.Widget = &newNode.widget
|
|
|
|
// a.Where = &n.widget
|
|
|
|
// action(&a)
|
|
|
|
newaction(&a, newNode, n)
|
|
|
|
|
2022-11-13 08:53:03 -06:00
|
|
|
return newNode
|
2022-10-20 06:55:42 -05:00
|
|
|
}
|