summaryrefslogtreecommitdiff
path: root/toolkit/gocui/common.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-12-14 10:36:56 -0600
committerJeff Carr <[email protected]>2023-12-14 10:36:56 -0600
commit282119d970faed3f8a60d5105a2f26ee14681ff4 (patch)
tree1680731c899f0e147487b9ba4d50ace2f3e96eb1 /toolkit/gocui/common.go
parent9d075afb1df62276dea06be4a188eaee8fc69420 (diff)
tabs, windows + gocui dropdown menu (almost)
dropdown menu figures out what text was clicked dropdown menu movement changes line colors dropdown menus force user to select a response accidentally committed a binary tab selection works tab and window views almost working tabs and windows almost working window widgets selection works better color handling using gocui view.Visable flag removal of old color setting code still need an artificial delay for andlabs SetText() catching more 'nil' errors fixed the stupid duplicate tab problem in andlabs figured out how andlabs had a tab/box mess works on more than one domain builds and runs again debugging double tabs in andlabs gui GO111MODULE compile notes code reorg further improvements example cloudflare app does first successful dns update add NewEntryLine() for single line entry boxes Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/gocui/common.go')
-rw-r--r--toolkit/gocui/common.go97
1 files changed, 62 insertions, 35 deletions
diff --git a/toolkit/gocui/common.go b/toolkit/gocui/common.go
index 05de64b..d3de34c 100644
--- a/toolkit/gocui/common.go
+++ b/toolkit/gocui/common.go
@@ -98,6 +98,46 @@ func (n *node) findWidgetName(name string) *node {
return nil
}
+func (n *node) IsCurrent() bool {
+ w := n.tk
+ if (n.WidgetType == toolkit.Tab) {
+ return w.isCurrent
+ }
+ if (n.WidgetType == toolkit.Window) {
+ return w.isCurrent
+ }
+ if (n.WidgetType == toolkit.Root) {
+ return false
+ }
+ return n.parent.IsCurrent()
+}
+
+func (n *node) Visible() bool {
+ if (n == nil) {
+ return false
+ }
+ if (n.tk == nil) {
+ return false
+ }
+ if (n.tk.v == nil) {
+ return false
+ }
+ return n.tk.v.Visible
+}
+
+func (n *node) SetVisible(b bool) {
+ if (n == nil) {
+ return
+ }
+ if (n.tk == nil) {
+ return
+ }
+ if (n.tk.v == nil) {
+ return
+ }
+ n.tk.v.Visible = b
+}
+
func addNode(a *toolkit.Action) *node {
n := new(node)
n.WidgetType = a.WidgetType
@@ -143,42 +183,29 @@ func addNode(a *toolkit.Action) *node {
return n
}
-func (n *node) IsCurrent() bool {
- w := n.tk
- if (n.WidgetType == toolkit.Tab) {
- return w.isCurrent
- }
- if (n.WidgetType == toolkit.Window) {
- return w.isCurrent
- }
- if (n.WidgetType == toolkit.Root) {
- return false
- }
- return n.parent.IsCurrent()
-}
+func addDropdown() *node {
+ n := new(node)
+ n.WidgetType = toolkit.Flag
+ n.WidgetId = -2
+ n.ParentId = 0
-func (n *node) Visible() bool {
- if (n == nil) {
- return false
- }
- if (n.tk == nil) {
- return false
- }
- if (n.tk.v == nil) {
- return false
- }
- return n.tk.v.Visible
-}
+ // copy the data from the action message
+ n.Name = "DropBox"
+ n.Text = "DropBox text"
-func (n *node) SetVisible(b bool) {
- if (n == nil) {
- return
- }
- if (n.tk == nil) {
- return
- }
- if (n.tk.v == nil) {
- return
+ // store the internal toolkit information
+ n.tk = new(cuiWidget)
+ n.tk.frame = true
+
+ // set the name used by gocui to the id
+ n.tk.cuiName = "-1 dropbox"
+
+ n.tk.color = &colorFlag
+
+ // add this new widget on the binary tree
+ n.parent = me.rootNode
+ if n.parent != nil {
+ n.parent.children = append(n.parent.children, n)
}
- n.tk.v.Visible = b
+ return n
}