package gui // Common actions for widgets like 'Enable' or 'Hide' import ( "go.wit.com/log" "go.wit.com/widget" ) // This will set the visable name for widgets that // have text displayed that is not editable by the user // For example, a button, window, group, checkbox func (n *Node) SetLabel(label string) *Node { switch n.WidgetType { case widget.Checkbox: n.label = label case widget.Button: n.label = label case widget.Label: if n.IsMirror() { // n is a mirror of something else log.Log(WARN, "SetLabel() error this widget is a mirror", n.id) } else { n.label = label n.updateMirrors() } case widget.Group: n.label = label case widget.Window: n.label = label default: } n.changed = true log.Log(CHANGE, "SetLabel() =", label) // inform the toolkits sendAction(n, widget.SetText) return n } // What "SetText" means depends on the type of widget // should this be a different name? func (n *Node) SetText(text string) *Node { n.newString = text n.changed = true log.Log(CHANGE, "SetText() text =", text) switch n.WidgetType { case widget.Checkbox: n.label = text case widget.Button: n.label = text case widget.Label: n.label = text case widget.Group: n.label = text case widget.Combobox: n.newString = text n.currentS = text n.defaultS = text case widget.Dropdown: n.newString = text n.currentS = text n.defaultS = text case widget.Textbox: n.currentS = text n.defaultS = text case widget.Window: n.label = text default: } // inform the toolkits sendAction(n, widget.SetText) return n }