diff options
| author | Jeff Carr <[email protected]> | 2024-01-17 21:21:29 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-17 21:21:29 -0600 |
| commit | a6a3e1193fa7c77165f3ed2eb0031f319b4abdd0 (patch) | |
| tree | 2c5a9fbf4dbc5f7bd5cb235542082da5eba342c6 /common.go | |
| parent | 8ef3fc7a73a004385d36561c6c8acc4be7e3e24b (diff) | |
work around a toolkit panic()v0.12.11
things should work when
GUI is not really there
Int() and Bool()
helloworld works
compiles and runs
RawWindow shouldn't auto exit
add StandardExit()
Signed-off-by: Jeff Carr <[email protected]>
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'common.go')
| -rw-r--r-- | common.go | 50 |
1 files changed, 32 insertions, 18 deletions
@@ -30,6 +30,7 @@ func (n *Node) Show() *Node { } func (n *Node) Hide() *Node { + return n if ! n.Ready() { return n } if n.Hidden() { return n } @@ -79,6 +80,35 @@ func (n *Node) Disable() *Node { return n } +func (n *Node) Bool() bool { + if ! n.Ready() { return false} + + return widget.GetBool(n.value) +} + +func (n *Node) Int() int { + if ! n.Ready() { return -1} + + return widget.GetInt(n.value) +} + +func (n *Node) String() string { + if ! n.Ready() { return ""} + + return widget.GetString(n.value) +} + +func (n *Node) Strings() []string { + if ! n.Ready() { return nil} + var tmp []string + + for s, _ := range n.strings { + tmp = append(tmp, s) + } + + return tmp +} + func (n *Node) Destroy() { if ! n.Ready() { return } // if ! n.enabled { return } @@ -91,24 +121,6 @@ func (n *Node) Destroy() { return } - -// add a new text string to widgets that support -// multiple string values -// These must be unique. return false if the string already exists -func (n *Node) AddText(str string) bool { - if ! n.Ready() { return false } - log.Log(CHANGE, "AddText() value =", str) - - n.value = str - // TODO: make sure these are unique - n.strings = append(n.strings, str) - - // inform the toolkits - sendAction(n, widget.AddText) - return true -} - - // appends text to the existing text // TODO: this is an experiement func (n *Node) AppendText(str string) { @@ -127,6 +139,7 @@ func (n *Node) AppendText(str string) { // Progname() Reference() ? // 2024/01/13 the names are starting to grow on me and make it clearer to code against +/* // get a string from the widget func (n *Node) GetText() string { if ! n.Ready() { return "" } @@ -144,6 +157,7 @@ func (n *Node) GetBool() bool { if ! n.Ready() { return false} return widget.GetBool(n.value) } +*/ // should get the reference name used for programming and debugging func (n *Node) SetProgName(s string) *Node { |
