dropdown & combobox's pop up
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
13b0daed7c
commit
dddef229dc
5
add.go
5
add.go
|
@ -49,6 +49,11 @@ func addWidget(n *tree.Node) {
|
||||||
nw.color = &colorWindow
|
nw.color = &colorWindow
|
||||||
wRoot := me.treeRoot.TK.(*guiWidget)
|
wRoot := me.treeRoot.TK.(*guiWidget)
|
||||||
wRoot.redoWindows(0, 0)
|
wRoot.redoWindows(0, 0)
|
||||||
|
// TODO: record the first window here?
|
||||||
|
// do initial setup of helper widgets here:
|
||||||
|
if me.ddview == nil {
|
||||||
|
me.ddview = makeDropdownView("addWidget() ddview")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
case widget.Tab:
|
case widget.Tab:
|
||||||
nw.color = &colorTab
|
nw.color = &colorTab
|
||||||
|
|
2
click.go
2
click.go
|
@ -198,9 +198,11 @@ func (w *guiWidget) doWidgetClick() {
|
||||||
log.Log(NOW, "ddItem:", w.String(), i, s)
|
log.Log(NOW, "ddItem:", w.String(), i, s)
|
||||||
ddItems += s + "\n"
|
ddItems += s + "\n"
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if me.ddview == nil {
|
if me.ddview == nil {
|
||||||
me.ddview = makeDropdownView(ddItems)
|
me.ddview = makeDropdownView(ddItems)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
showDropdownItems(ddItems)
|
showDropdownItems(ddItems)
|
||||||
me.ddNode = w.node
|
me.ddNode = w.node
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -155,12 +155,13 @@ func showDDview() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// if there is a drop down view active, treat it like a dialog box and close it
|
// if there is a drop down view active, treat it like a dialog box and close it
|
||||||
|
|
||||||
if (hideDDview() == nil) {
|
if (hideDDview() == nil) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
func (w *guiWidget) dropdownClicked(mouseW, mouseH int) {
|
func (w *guiWidget) dropdownClicked(mouseW, mouseH int) {
|
||||||
log.Log(NOW, "dropdownClicked() (w,h) =", mouseW, mouseH)
|
log.Log(NOW, "dropdownClicked() (w,h) =", mouseW, mouseH)
|
||||||
w.SetVisible(false)
|
w.SetVisible(false)
|
||||||
|
|
29
gocui.go
29
gocui.go
|
@ -12,35 +12,6 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This initializes the gocui package
|
|
||||||
// it runs SetManagerFunc which passes every input
|
|
||||||
// event (keyboard, mouse, etc) to the function "gocuiEvent()"
|
|
||||||
func gocuiMain() {
|
|
||||||
g, err := gocui.NewGui(gocui.OutputNormal, true)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer g.Close()
|
|
||||||
|
|
||||||
me.baseGui = g
|
|
||||||
|
|
||||||
g.Cursor = true
|
|
||||||
g.Mouse = true
|
|
||||||
|
|
||||||
// this sets the function that is run on every event. For example:
|
|
||||||
// When you click the mouse, move the mouse, or press a key on the keyboard
|
|
||||||
// This is equivalent to xev or similar to cat /dev/input on linux
|
|
||||||
g.SetManagerFunc(gocuiEvent)
|
|
||||||
|
|
||||||
if err := defaultKeybindings(g); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := g.MainLoop(); err != nil && !errors.Is(err, gocui.ErrQuit) {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Thanks to the gocui developers -- your package kicks ass
|
// Thanks to the gocui developers -- your package kicks ass
|
||||||
// This function is called on every event. It is a callback function from the gocui package
|
// This function is called on every event. It is a callback function from the gocui package
|
||||||
// which has an excellent implementation. While gocui handles things like text highlighting
|
// which has an excellent implementation. While gocui handles things like text highlighting
|
||||||
|
|
42
main.go
42
main.go
|
@ -5,9 +5,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
|
||||||
|
"github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
@ -75,14 +77,19 @@ func mainGogui() {
|
||||||
log.Warn("YAHOOOO Recovered in guiMain application:", r)
|
log.Warn("YAHOOOO Recovered in guiMain application:", r)
|
||||||
log.Warn("Recovered from panic:", r)
|
log.Warn("Recovered from panic:", r)
|
||||||
me.baseGui.Close()
|
me.baseGui.Close()
|
||||||
log.Sleep(3)
|
|
||||||
|
// allow gocui to close if possible, then print stack
|
||||||
|
log.Sleep(1)
|
||||||
os.Stdout = origStdout
|
os.Stdout = origStdout
|
||||||
os.Stderr = origStderr
|
os.Stderr = origStderr
|
||||||
|
|
||||||
me.myTree.SendToolkitPanic()
|
me.myTree.SendToolkitPanic()
|
||||||
log.Warn("Stack trace:")
|
log.Warn("Stack trace:")
|
||||||
debug.PrintStack()
|
debug.PrintStack()
|
||||||
panic("BUMMER")
|
|
||||||
|
// attempt to switch to the nocui toolkit
|
||||||
|
log.Sleep(1)
|
||||||
|
me.myTree.SendToolkitLoad("nocui")
|
||||||
|
// panic("BUMMER")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -106,3 +113,32 @@ func mainGogui() {
|
||||||
os.Stderr = ferr
|
os.Stderr = ferr
|
||||||
gocuiMain()
|
gocuiMain()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This initializes the gocui package
|
||||||
|
// it runs SetManagerFunc which passes every input
|
||||||
|
// event (keyboard, mouse, etc) to the function "gocuiEvent()"
|
||||||
|
func gocuiMain() {
|
||||||
|
g, err := gocui.NewGui(gocui.OutputNormal, true)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer g.Close()
|
||||||
|
|
||||||
|
me.baseGui = g
|
||||||
|
|
||||||
|
g.Cursor = true
|
||||||
|
g.Mouse = true
|
||||||
|
|
||||||
|
// this sets the function that is run on every event. For example:
|
||||||
|
// When you click the mouse, move the mouse, or press a key on the keyboard
|
||||||
|
// This is equivalent to xev or similar to cat /dev/input on linux
|
||||||
|
g.SetManagerFunc(gocuiEvent)
|
||||||
|
|
||||||
|
if err := defaultKeybindings(g); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := g.MainLoop(); err != nil && !errors.Is(err, gocui.ErrQuit) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue