basic start of a stubbed out 'textbox' entry box

This commit is contained in:
Jeff Carr 2025-02-06 23:49:18 -06:00
parent 7e47ca9843
commit c2f8cac4a9
4 changed files with 38 additions and 10 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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()

View File

@ -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?
}