still loads and displays window widget
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b302e33186
commit
70f5c88640
19
click.go
19
click.go
|
@ -205,9 +205,7 @@ func doWidgetClick(n *tree.Node) {
|
|||
log.Log(NOW, "do the dropdown here")
|
||||
if me.ddview == nil {
|
||||
me.ddview = addDropdown()
|
||||
// n.TK = initWidget(n)
|
||||
var tk *guiWidget
|
||||
tk = me.ddview.TK.(*guiWidget)
|
||||
tk := me.ddview.TK.(*guiWidget)
|
||||
tk.gocuiSize.w0 = 20
|
||||
tk.gocuiSize.w1 = 40
|
||||
tk.gocuiSize.h0 = 10
|
||||
|
@ -224,14 +222,14 @@ func doWidgetClick(n *tree.Node) {
|
|||
tk.v.Frame = true
|
||||
tk.v.Clear()
|
||||
fmt.Fprint(tk.v, "example.com\nwit.com")
|
||||
SetVisible(me.ddview, true)
|
||||
tk.SetVisible(true)
|
||||
return
|
||||
}
|
||||
log.Log(NOW, "doWidgetClick() visible =", Visible(me.ddview))
|
||||
var tk *guiWidget
|
||||
tk = me.ddview.TK.(*guiWidget)
|
||||
if Visible(me.ddview) {
|
||||
SetVisible(me.ddview, false)
|
||||
log.Log(NOW, "doWidgetClick() visible =", tk.Visible())
|
||||
if tk.Visible() {
|
||||
tk.SetVisible(false)
|
||||
me.baseGui.DeleteView("ddview")
|
||||
tk.v = nil
|
||||
} else {
|
||||
|
@ -244,7 +242,7 @@ func doWidgetClick(n *tree.Node) {
|
|||
log.Log(NOW, "new dns list should be set to:", dnsList)
|
||||
tk.labelN = dnsList
|
||||
tk.SetText(dnsList)
|
||||
SetVisible(me.ddview, true)
|
||||
tk.SetVisible(true)
|
||||
}
|
||||
for i, s := range tk.vals {
|
||||
log.Log(NOW, "AddText()", tk.String(), i, s)
|
||||
|
@ -328,7 +326,7 @@ func findUnderMouse() *tree.Node {
|
|||
var widget *guiWidget
|
||||
widget = n.TK.(*guiWidget)
|
||||
// ignore widgets that are not visible
|
||||
if Visible(n) {
|
||||
if widget.Visible() {
|
||||
if (widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
|
||||
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1) {
|
||||
widgets = append(widgets, n)
|
||||
|
@ -336,8 +334,9 @@ func findUnderMouse() *tree.Node {
|
|||
}
|
||||
}
|
||||
if n == me.ddview {
|
||||
tk := me.ddview.TK.(*guiWidget)
|
||||
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")
|
||||
found = n
|
||||
// find the actual value here and set the dropdown widget
|
||||
|
|
8
mouse.go
8
mouse.go
|
@ -47,7 +47,7 @@ func hideDDview() error {
|
|||
if tk.v == nil {
|
||||
return gocui.ErrUnknownView
|
||||
}
|
||||
SetVisible(me.ddview, false)
|
||||
tk.SetVisible(false)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ func showDDview() error {
|
|||
if tk.v == nil {
|
||||
return gocui.ErrUnknownView
|
||||
}
|
||||
SetVisible(me.ddview, true)
|
||||
tk.SetVisible(true)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,6 @@ func makeDropdownView() {
|
|||
tk.v.Frame = true
|
||||
tk.v.Clear()
|
||||
fmt.Fprint(tk.v, "example.com\nwit.com")
|
||||
// SetVisible(me.ddview, true)
|
||||
}
|
||||
|
||||
func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
||||
|
@ -168,7 +167,8 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
|||
test := findUnderMouse()
|
||||
msg := fmt.Sprintf("Mouse really down at: %d,%d", mx, my) + "foobar"
|
||||
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)
|
||||
hideDDview()
|
||||
} else {
|
||||
|
|
|
@ -66,12 +66,12 @@ func action(a widget.Action) {
|
|||
// widget was already shown
|
||||
} else {
|
||||
log.Log(INFO, "Setting Visible to true", a.ProgName)
|
||||
SetVisible(n, true)
|
||||
w.SetVisible(true)
|
||||
}
|
||||
case widget.Disable:
|
||||
if w.Visible() {
|
||||
log.Log(INFO, "Setting Visible to false", a.ProgName)
|
||||
SetVisible(n, false)
|
||||
w.SetVisible(false)
|
||||
} else {
|
||||
// widget was already hidden
|
||||
}
|
||||
|
|
2
view.go
2
view.go
|
@ -48,7 +48,7 @@ func (w *guiWidget) textResize() bool {
|
|||
}
|
||||
|
||||
func (w *guiWidget) hideView() {
|
||||
SetVisible(w.node, false)
|
||||
w.SetVisible(false)
|
||||
}
|
||||
|
||||
// display's the text of the widget in gocui
|
||||
|
|
17
widget.go
17
widget.go
|
@ -120,6 +120,7 @@ func (tk *guiWidget) Visible() bool {
|
|||
return tk.v.Visible
|
||||
}
|
||||
|
||||
/*
|
||||
func Visible(n *tree.Node) bool {
|
||||
if n == nil {
|
||||
return false
|
||||
|
@ -131,6 +132,7 @@ func Visible(n *tree.Node) bool {
|
|||
w = n.TK.(*guiWidget)
|
||||
return w.Visible()
|
||||
}
|
||||
*/
|
||||
|
||||
func (w *guiWidget) SetVisible(b bool) {
|
||||
if w.v == nil {
|
||||
|
@ -139,21 +141,6 @@ func (w *guiWidget) SetVisible(b bool) {
|
|||
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 {
|
||||
n := new(tree.Node)
|
||||
n.WidgetType = widget.Flag
|
||||
|
|
Loading…
Reference in New Issue