still loads and displays window widget

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-28 10:38:47 -06:00
parent b302e33186
commit 70f5c88640
5 changed files with 18 additions and 32 deletions

View File

@ -205,9 +205,7 @@ func doWidgetClick(n *tree.Node) {
log.Log(NOW, "do the dropdown here") log.Log(NOW, "do the dropdown here")
if me.ddview == nil { if me.ddview == nil {
me.ddview = addDropdown() me.ddview = addDropdown()
// n.TK = initWidget(n) tk := me.ddview.TK.(*guiWidget)
var tk *guiWidget
tk = me.ddview.TK.(*guiWidget)
tk.gocuiSize.w0 = 20 tk.gocuiSize.w0 = 20
tk.gocuiSize.w1 = 40 tk.gocuiSize.w1 = 40
tk.gocuiSize.h0 = 10 tk.gocuiSize.h0 = 10
@ -224,14 +222,14 @@ func doWidgetClick(n *tree.Node) {
tk.v.Frame = true tk.v.Frame = true
tk.v.Clear() tk.v.Clear()
fmt.Fprint(tk.v, "example.com\nwit.com") fmt.Fprint(tk.v, "example.com\nwit.com")
SetVisible(me.ddview, true) tk.SetVisible(true)
return return
} }
log.Log(NOW, "doWidgetClick() visible =", Visible(me.ddview))
var tk *guiWidget var tk *guiWidget
tk = me.ddview.TK.(*guiWidget) tk = me.ddview.TK.(*guiWidget)
if Visible(me.ddview) { log.Log(NOW, "doWidgetClick() visible =", tk.Visible())
SetVisible(me.ddview, false) if tk.Visible() {
tk.SetVisible(false)
me.baseGui.DeleteView("ddview") me.baseGui.DeleteView("ddview")
tk.v = nil tk.v = nil
} else { } else {
@ -244,7 +242,7 @@ func doWidgetClick(n *tree.Node) {
log.Log(NOW, "new dns list should be set to:", dnsList) log.Log(NOW, "new dns list should be set to:", dnsList)
tk.labelN = dnsList tk.labelN = dnsList
tk.SetText(dnsList) tk.SetText(dnsList)
SetVisible(me.ddview, true) tk.SetVisible(true)
} }
for i, s := range tk.vals { for i, s := range tk.vals {
log.Log(NOW, "AddText()", tk.String(), i, s) log.Log(NOW, "AddText()", tk.String(), i, s)
@ -328,7 +326,7 @@ func findUnderMouse() *tree.Node {
var widget *guiWidget var widget *guiWidget
widget = n.TK.(*guiWidget) widget = n.TK.(*guiWidget)
// ignore widgets that are not visible // ignore widgets that are not visible
if Visible(n) { if widget.Visible() {
if (widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) && if (widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1) { (widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1) {
widgets = append(widgets, n) widgets = append(widgets, n)
@ -336,8 +334,9 @@ func findUnderMouse() *tree.Node {
} }
} }
if n == me.ddview { if n == me.ddview {
tk := me.ddview.TK.(*guiWidget)
log.Log(NOW, "findUnderMouse() found ddview") log.Log(NOW, "findUnderMouse() found ddview")
if Visible(n) { if tk.Visible() {
log.Log(NOW, "findUnderMouse() and ddview is visable. hide it here. TODO: find highlighted row") log.Log(NOW, "findUnderMouse() and ddview is visable. hide it here. TODO: find highlighted row")
found = n found = n
// find the actual value here and set the dropdown widget // find the actual value here and set the dropdown widget

View File

@ -47,7 +47,7 @@ func hideDDview() error {
if tk.v == nil { if tk.v == nil {
return gocui.ErrUnknownView return gocui.ErrUnknownView
} }
SetVisible(me.ddview, false) tk.SetVisible(false)
return nil return nil
} }
@ -62,7 +62,7 @@ func showDDview() error {
if tk.v == nil { if tk.v == nil {
return gocui.ErrUnknownView return gocui.ErrUnknownView
} }
SetVisible(me.ddview, true) tk.SetVisible(true)
return nil return nil
} }
@ -90,7 +90,6 @@ func makeDropdownView() {
tk.v.Frame = true tk.v.Frame = true
tk.v.Clear() tk.v.Clear()
fmt.Fprint(tk.v, "example.com\nwit.com") fmt.Fprint(tk.v, "example.com\nwit.com")
// SetVisible(me.ddview, true)
} }
func mouseUp(g *gocui.Gui, v *gocui.View) error { func mouseUp(g *gocui.Gui, v *gocui.View) error {
@ -168,7 +167,8 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
test := findUnderMouse() test := findUnderMouse()
msg := fmt.Sprintf("Mouse really down at: %d,%d", mx, my) + "foobar" msg := fmt.Sprintf("Mouse really down at: %d,%d", mx, my) + "foobar"
if test == me.ddview { if test == me.ddview {
if Visible(me.ddview) { tk := me.ddview.TK.(*guiWidget)
if tk.Visible() {
log.Log(NOW, "hide DDview() Mouse really down at:", mx, my) log.Log(NOW, "hide DDview() Mouse really down at:", mx, my)
hideDDview() hideDDview()
} else { } else {

View File

@ -66,12 +66,12 @@ func action(a widget.Action) {
// widget was already shown // widget was already shown
} else { } else {
log.Log(INFO, "Setting Visible to true", a.ProgName) log.Log(INFO, "Setting Visible to true", a.ProgName)
SetVisible(n, true) w.SetVisible(true)
} }
case widget.Disable: case widget.Disable:
if w.Visible() { if w.Visible() {
log.Log(INFO, "Setting Visible to false", a.ProgName) log.Log(INFO, "Setting Visible to false", a.ProgName)
SetVisible(n, false) w.SetVisible(false)
} else { } else {
// widget was already hidden // widget was already hidden
} }

View File

@ -48,7 +48,7 @@ func (w *guiWidget) textResize() bool {
} }
func (w *guiWidget) hideView() { func (w *guiWidget) hideView() {
SetVisible(w.node, false) w.SetVisible(false)
} }
// display's the text of the widget in gocui // display's the text of the widget in gocui

View File

@ -120,6 +120,7 @@ func (tk *guiWidget) Visible() bool {
return tk.v.Visible return tk.v.Visible
} }
/*
func Visible(n *tree.Node) bool { func Visible(n *tree.Node) bool {
if n == nil { if n == nil {
return false return false
@ -131,6 +132,7 @@ func Visible(n *tree.Node) bool {
w = n.TK.(*guiWidget) w = n.TK.(*guiWidget)
return w.Visible() return w.Visible()
} }
*/
func (w *guiWidget) SetVisible(b bool) { func (w *guiWidget) SetVisible(b bool) {
if w.v == nil { if w.v == nil {
@ -139,21 +141,6 @@ func (w *guiWidget) SetVisible(b bool) {
w.v.Visible = b w.v.Visible = b
} }
func SetVisible(n *tree.Node, b bool) {
if n == nil {
return
}
if n.TK == nil {
return
}
var w *guiWidget
w = n.TK.(*guiWidget)
if w.v == nil {
return
}
w.v.Visible = b
}
func addDropdown() *tree.Node { func addDropdown() *tree.Node {
n := new(tree.Node) n := new(tree.Node)
n.WidgetType = widget.Flag n.WidgetType = widget.Flag