diff --git a/dropdown.go b/dropdown.go index f426fc0..f14e54b 100644 --- a/dropdown.go +++ b/dropdown.go @@ -23,6 +23,7 @@ import ( // screen debugging output I might be able to figure it // it out now. maybe. notsure. +/* func makeDropdownView(ddItems string) *guiWidget { newNode := addDropdown() tk := newNode.TK.(*guiWidget) @@ -47,6 +48,7 @@ func makeDropdownView(ddItems string) *guiWidget { tk.Show() return tk } +*/ func addDropdownTK(wId int) *guiWidget { n := addDropdownNew(wId) @@ -99,7 +101,7 @@ func (tk *guiWidget) showDropdown() { log.Log(GOCUI, "new dropdown items should be set to:", me.dropdown.items) if me.dropdown.tk == nil { - me.dropdown.tk = addDropdownTK(-77) + me.dropdown.tk = addDropdownTK(me.dropdown.wId) } if me.dropdown.tk == nil { log.Log(GOCUI, "showDropdown() IS BROKEN") @@ -159,3 +161,22 @@ func dropdownUnclicked(w, h int) { } // log.Log(GOCUI, "dropdownUnclicked()", d.node.Strings(), "end. now try to enable me.dropdownV") } + +func (tk *guiWidget) showTextbox() { + // todo: fix this after switching to protobuf + + if me.textbox.tk == nil { + me.textbox.tk = addDropdownTK(me.textbox.wId) + } + if me.textbox.tk == nil { + log.Log(GOCUI, "showDropdown() IS BROKEN") + return + } + startW, startH := tk.Position() + log.Log(GOCUI, "showDropdown() SHOWING AT W,H=", startW, startH) + me.textbox.tk.MoveToOffset(startW+3, startH+2) + me.textbox.tk.labelN = "holy cow" + me.textbox.tk.Show() + me.textbox.active = true + me.textbox.callerTK = tk +} diff --git a/eventMouseClick.go b/eventMouseClick.go index 57c4580..ca361b7 100644 --- a/eventMouseClick.go +++ b/eventMouseClick.go @@ -96,6 +96,8 @@ func (tk *guiWidget) doWidgetClick(w int, h int) { tk.showDropdown() case widget.Dropdown: tk.showDropdown() + case widget.Textbox: + tk.showTextbox() case widget.Flag: tk.dropdownClicked(w, h) default: @@ -104,7 +106,7 @@ func (tk *guiWidget) doWidgetClick(w int, h int) { } // sends the mouse click to a widget underneath -func click(g *gocui.Gui, v *gocui.View) error { +func clickOLD(g *gocui.Gui, v *gocui.View) error { mouseW, mouseH := me.baseGui.MousePosition() w := mouseW diff --git a/init.go b/init.go index 8439097..8bff631 100644 --- a/init.go +++ b/init.go @@ -44,6 +44,10 @@ func init() { me.stdout.lastW = 30 me.stdout.lastH = 10 + // just make up unique values for these + me.dropdown.wId = -77 + me.textbox.wId = -55 + // Set(&me, "dense") me.myTree = tree.New() diff --git a/structs.go b/structs.go index 186d228..e24ea21 100644 --- a/structs.go +++ b/structs.go @@ -28,14 +28,13 @@ var me config // it got me here, but now it's time to clean it up for good // I can't get a GO plugins that use protobuf to load yet (versioning mismatch) type config struct { - baseGui *gocui.Gui // the main gocui handle - treeRoot *tree.Node // the base of the binary tree. it should have id == 0 - myTree *tree.TreeInfo // ? - ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed - currentWindow *guiWidget // this is the current tab or window to show - helpLabel *gocui.View // ? - showHelp bool // toggle boolean for the help menu (deprecate?) - // dropdownW *guiWidget // grab the dropdown choices from this widget + baseGui *gocui.Gui // the main gocui handle + treeRoot *tree.Node // the base of the binary tree. it should have id == 0 + myTree *tree.TreeInfo // ? + ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed + currentWindow *guiWidget // this is the current tab or window to show + helpLabel *gocui.View // ? + showHelp bool // toggle boolean for the help menu (deprecate?) FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side PadW int `default:"1" dense:"0"` // pad spacing @@ -67,6 +66,7 @@ type config struct { stdout stdout // information for the STDOUT window showDebug bool // todo: move this into config struct dropdown dropdown // the dropdown menu + textbox dropdown // the textbox popup window allwin []*guiWidget // for tracking which window is next downW int // where the mouse was pressed down downH int // where the mouse was pressed down @@ -100,6 +100,7 @@ type dropdown struct { h int // the height active bool // is the dropdown menu currently in use? init bool // moves the window offscreen on startup + wId int // the widget id to use // dtoggle bool // is a dropdown or combobox currently active? }