fake buttons have labels
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
1f3d664dbd
commit
e678a5cc62
|
@ -8,14 +8,17 @@ func (w *guiWidget) setCheckbox(b any) {
|
|||
if w.node.WidgetType != widget.Checkbox {
|
||||
return
|
||||
}
|
||||
if w.node.State.Label == "" {
|
||||
w.node.State.Label = "BLANK"
|
||||
}
|
||||
if widget.GetBool(b) {
|
||||
w.checked = widget.GetBool(b)
|
||||
w.label = "X " + w.label
|
||||
w.labelN = "X " + w.node.State.Label
|
||||
} else {
|
||||
w.checked = widget.GetBool(b)
|
||||
w.label = " " + w.label
|
||||
w.labelN = " " + w.node.State.Label
|
||||
}
|
||||
t := len(w.label) + 1
|
||||
t := len(w.labelN) + 1
|
||||
w.gocuiSize.w1 = w.gocuiSize.w0 + t
|
||||
|
||||
// w.realWidth = w.gocuiSize.Width() + me.PadW
|
||||
|
|
8
click.go
8
click.go
|
@ -242,7 +242,7 @@ func doWidgetClick(n *tree.Node) {
|
|||
}
|
||||
me.ddNode = n
|
||||
log.Log(NOW, "new dns list should be set to:", dnsList)
|
||||
tk.label = dnsList
|
||||
tk.labelN = dnsList
|
||||
tk.SetText(dnsList)
|
||||
SetVisible(me.ddview, true)
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ func click(g *gocui.Gui, v *gocui.View) error {
|
|||
var w *guiWidget
|
||||
w = n.TK.(*guiWidget)
|
||||
if n != nil {
|
||||
log.Log(NOW, "click() Found widget =", n.WidgetId, n.String(), ",", w.label)
|
||||
log.Log(NOW, "click() Found widget =", n.WidgetId, n.String(), ",", w.labelN)
|
||||
if n.String() == "DropBox" {
|
||||
log.Log(NOW, "click() this is the dropdown menu. set a flag here what did I click? where is the mouse?")
|
||||
log.Log(NOW, "click() set a global dropdown clicked flag=true here")
|
||||
|
@ -372,7 +372,7 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
var tk *guiWidget
|
||||
tk = me.ctrlDown.TK.(*guiWidget)
|
||||
tk.label = found.String()
|
||||
tk.labelN = found.String()
|
||||
tk.cuiName = "ctrlDown"
|
||||
// me.ctrlDown.parent = me.rootNode
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
|
|||
if found == nil {
|
||||
found = me.treeRoot
|
||||
}
|
||||
tk.label = found.String()
|
||||
tk.labelN = found.String()
|
||||
newR := realGocuiSize(found)
|
||||
tk.gocuiSize.w0 = newR.w0
|
||||
tk.gocuiSize.h0 = newR.h0
|
||||
|
|
4
debug.go
4
debug.go
|
@ -46,7 +46,7 @@ func (w *guiWidget) showWidgetPlacement(b bool, s string) {
|
|||
w.gocuiSize.Width(), w.gocuiSize.Height(),
|
||||
w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
|
||||
} else {
|
||||
s1 += fmt.Sprintf(" ")
|
||||
s1 += fmt.Sprintf(" w.Visable() == false ")
|
||||
}
|
||||
if w.node.Parent != nil {
|
||||
if w.node.Parent.WidgetType == widget.Grid {
|
||||
|
@ -54,7 +54,7 @@ func (w *guiWidget) showWidgetPlacement(b bool, s string) {
|
|||
}
|
||||
}
|
||||
tmp := "." + w.String() + "."
|
||||
log.Log(INFO, s1, s, w.node.WidgetType, ",", tmp) // , "text=", w.text)
|
||||
log.Log(INFO, s1, s, w.node.WidgetType, ",", tmp, "jcarr") // , "text=", w.text)
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -99,8 +99,8 @@ func (w *guiWidget) SetText(text string) {
|
|||
log.Log(NOW, "widget is nil")
|
||||
return
|
||||
}
|
||||
if widget.GetString(w.value) != text {
|
||||
w.value = text
|
||||
if w.labelN != text {
|
||||
w.labelN = text
|
||||
changed = true
|
||||
}
|
||||
if !changed {
|
||||
|
|
|
@ -139,7 +139,7 @@ type guiWidget struct {
|
|||
checked bool
|
||||
|
||||
// the actual text to display in the console
|
||||
label string
|
||||
labelN string
|
||||
|
||||
vals []string // dropdown menu items
|
||||
|
||||
|
@ -148,7 +148,7 @@ type guiWidget struct {
|
|||
|
||||
direction widget.Orientation
|
||||
|
||||
progname string
|
||||
// progname string
|
||||
|
||||
// the logical size of the widget
|
||||
// For example, 40x12 would be the center of a normal terminal
|
||||
|
|
15
view.go
15
view.go
|
@ -26,7 +26,7 @@ func (w *guiWidget) textResize() bool {
|
|||
var width, height int = 0, 0
|
||||
var changed bool = false
|
||||
|
||||
for i, s := range splitLines(w.label) {
|
||||
for i, s := range splitLines(w.labelN) {
|
||||
log.Log(INFO, "textResize() len =", len(s), i, s)
|
||||
if width < len(s) {
|
||||
width = len(s)
|
||||
|
@ -60,6 +60,7 @@ func (w *guiWidget) showView() {
|
|||
log.Log(ERROR, "showView() w.cuiName was not set for widget", w)
|
||||
w.cuiName = string(w.node.WidgetId)
|
||||
}
|
||||
log.Log(ERROR, "showView() labelN =", w.labelN)
|
||||
|
||||
// if the gocui element doesn't exist, create it
|
||||
if w.v == nil {
|
||||
|
@ -76,7 +77,7 @@ func (w *guiWidget) showView() {
|
|||
} else {
|
||||
log.Log(NOW, "showView() Clear() and Fprint() here wId =", w.cuiName)
|
||||
w.v.Clear()
|
||||
fmt.Fprint(w.v, w.label)
|
||||
fmt.Fprint(w.v, w.labelN)
|
||||
w.SetVisible(false)
|
||||
w.SetVisible(true)
|
||||
return
|
||||
|
@ -122,10 +123,10 @@ func (w *guiWidget) recreateView() {
|
|||
w.v = nil
|
||||
|
||||
if w.String() == "CLOUDFLARE_EMAIL" {
|
||||
w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.label+" "+w.cuiName)
|
||||
w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.labelN+" "+w.cuiName)
|
||||
// w.dumpWidget("jwc")
|
||||
w.textResize()
|
||||
w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.label+" "+w.cuiName)
|
||||
w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.labelN+" "+w.cuiName)
|
||||
}
|
||||
|
||||
a := w.gocuiSize.w0
|
||||
|
@ -159,7 +160,7 @@ func (w *guiWidget) recreateView() {
|
|||
w.v.Wrap = true
|
||||
w.v.Frame = w.frame
|
||||
w.v.Clear()
|
||||
fmt.Fprint(w.v, w.label)
|
||||
fmt.Fprint(w.v, w.labelN)
|
||||
// n.showWidgetPlacement(true, "n.String()=" + n.String() + " n.tk.label=" + n.tk.label + " " + w.cuiName)
|
||||
// n.dumpWidget("jwc 2")
|
||||
|
||||
|
@ -172,7 +173,7 @@ func (w *guiWidget) recreateView() {
|
|||
w.v.SelBgColor = w.color.selBg
|
||||
}
|
||||
if w.String() == "CLOUDFLARE_EMAIL" {
|
||||
w.showWidgetPlacement(true, "w.String()="+w.String()+" w.label="+w.label+" "+w.cuiName)
|
||||
w.showWidgetPlacement(true, "w.String()="+w.String()+" w.label="+w.labelN+" "+w.cuiName)
|
||||
dumpTree(w.node, true)
|
||||
}
|
||||
log.Log(ERROR, "recreateView() END")
|
||||
|
@ -206,8 +207,8 @@ func (w *guiWidget) hideFake() {
|
|||
func (w *guiWidget) showFake() {
|
||||
if w.isFake {
|
||||
// w.setFake()
|
||||
w.showWidgetPlacement(true, "showFake:")
|
||||
w.showView()
|
||||
w.showWidgetPlacement(true, "showFake:")
|
||||
}
|
||||
for _, child := range w.children {
|
||||
child.showFake()
|
||||
|
|
10
widget.go
10
widget.go
|
@ -18,6 +18,10 @@ func initWidget(n *tree.Node) *guiWidget {
|
|||
|
||||
w.node = n
|
||||
w.WidgetType = n.WidgetType
|
||||
w.labelN = n.State.Label
|
||||
if w.labelN == "" {
|
||||
w.labelN = n.GetProgName()
|
||||
}
|
||||
|
||||
if n.WidgetType == widget.Root {
|
||||
log.Log(INFO, "setupWidget() FOUND ROOT w.id =", n.WidgetId)
|
||||
|
@ -104,7 +108,7 @@ func (w *guiWidget) IsCurrent() bool {
|
|||
}
|
||||
|
||||
func (tk *guiWidget) String() string {
|
||||
return tk.progname
|
||||
return tk.node.String()
|
||||
}
|
||||
|
||||
func (tk *guiWidget) Visible() bool {
|
||||
|
@ -160,10 +164,10 @@ func addDropdown() *tree.Node {
|
|||
// store the internal toolkit information
|
||||
tk := new(guiWidget)
|
||||
tk.frame = true
|
||||
tk.label = "DropBox text"
|
||||
tk.labelN = "DropBox text"
|
||||
|
||||
// copy the data from the action message
|
||||
tk.progname = "DropBox"
|
||||
tk.node.State.Label = "DropBox"
|
||||
|
||||
// set the name used by gocui to the id
|
||||
tk.cuiName = "-1 dropbox"
|
||||
|
|
Loading…
Reference in New Issue