parent
ee0f84fd8e
commit
29d6cadbb3
21
click.go
21
click.go
|
@ -183,9 +183,11 @@ func (w *guiWidget) doWidgetClick() {
|
||||||
case widget.Combobox:
|
case widget.Combobox:
|
||||||
log.Log(NOW, "do the combobox here")
|
log.Log(NOW, "do the combobox here")
|
||||||
w.showDropdown()
|
w.showDropdown()
|
||||||
|
me.dropdownW = w
|
||||||
case widget.Dropdown:
|
case widget.Dropdown:
|
||||||
log.Log(NOW, "do the dropdown here")
|
log.Log(NOW, "do the dropdown here")
|
||||||
w.showDropdown()
|
w.showDropdown()
|
||||||
|
me.dropdownW = w
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,12 +223,19 @@ func (w *guiWidget) drawTree(draw bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func click(g *gocui.Gui, v *gocui.View) error {
|
func click(g *gocui.Gui, v *gocui.View) error {
|
||||||
// var l string
|
mouseW, mouseH := me.baseGui.MousePosition()
|
||||||
// var err error
|
|
||||||
|
|
||||||
log.Log(NOW, "click() START gocui name:", v.Name())
|
log.Log(NOW, "click() START gocui name:", v.Name())
|
||||||
// n := me.rootNode.findWidgetName(v.Name())
|
|
||||||
w := findUnderMouse()
|
w := findUnderMouse()
|
||||||
|
|
||||||
|
// if the dropdown view is visable, process it no matter what
|
||||||
|
if me.dropdownV.Visible() {
|
||||||
|
me.dropdownV.dropdownClicked(mouseW, mouseH)
|
||||||
|
}
|
||||||
|
if w == me.dropdownV {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if w == nil {
|
if w == nil {
|
||||||
log.Error(errors.New("click() could not find widget for view =" + v.Name()))
|
log.Error(errors.New("click() could not find widget for view =" + v.Name()))
|
||||||
} else {
|
} else {
|
||||||
|
@ -270,12 +279,6 @@ func findUnderMouse() *guiWidget {
|
||||||
var f func(w *guiWidget)
|
var f func(w *guiWidget)
|
||||||
w, h := me.baseGui.MousePosition()
|
w, h := me.baseGui.MousePosition()
|
||||||
|
|
||||||
// if the dropdown view is visable, close it
|
|
||||||
if me.dropdownV.Visible() {
|
|
||||||
me.dropdownV.dropdownClicked(w, h)
|
|
||||||
return me.dropdownV
|
|
||||||
}
|
|
||||||
|
|
||||||
// find buttons that are below where the mouse button click
|
// find buttons that are below where the mouse button click
|
||||||
f = func(widget *guiWidget) {
|
f = func(widget *guiWidget) {
|
||||||
// ignore widgets that are not visible
|
// ignore widgets that are not visible
|
||||||
|
|
31
dropdown.go
31
dropdown.go
|
@ -131,6 +131,13 @@ func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
|
||||||
items := strings.Split(w.labelN, "\n")
|
items := strings.Split(w.labelN, "\n")
|
||||||
if len(items) >= itemNumber-1 {
|
if len(items) >= itemNumber-1 {
|
||||||
log.Log(NOW, "dropdownClicked() found", items[itemNumber-1])
|
log.Log(NOW, "dropdownClicked() found", items[itemNumber-1])
|
||||||
|
if items[itemNumber-1] != "" {
|
||||||
|
if me.dropdownW != nil {
|
||||||
|
log.Log(NOW, "dropdownClicked() send event for", me.dropdownW.cuiName, me.dropdownW.WidgetType)
|
||||||
|
me.dropdownW.SetText(items[itemNumber-1])
|
||||||
|
me.myTree.SendUserEvent(me.dropdownW.node)
|
||||||
|
}
|
||||||
|
}
|
||||||
return items[itemNumber-1]
|
return items[itemNumber-1]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
@ -141,28 +148,4 @@ func dropdownUnclicked(mouseX, mouseH int) {
|
||||||
log.Log(NOW, "mouseUp() view msgMouseDown (check here for dropdown menu click) (w,h) =", mouseX, mouseH)
|
log.Log(NOW, "mouseUp() view msgMouseDown (check here for dropdown menu click) (w,h) =", mouseX, mouseH)
|
||||||
log.Log(NOW, "mouseUp() ddview is the thing that was clicked", mouseX, mouseH)
|
log.Log(NOW, "mouseUp() ddview is the thing that was clicked", mouseX, mouseH)
|
||||||
log.Log(NOW, "mouseUp() find out what the string is here", mouseX, mouseH, tk.gocuiSize.h1)
|
log.Log(NOW, "mouseUp() find out what the string is here", mouseX, mouseH, tk.gocuiSize.h1)
|
||||||
|
|
||||||
var newZone string = ""
|
|
||||||
if me.dropdownW == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// try to compute the line item clicked here
|
|
||||||
/*
|
|
||||||
var ddtk *guiWidget
|
|
||||||
ddtk = me.ddview.TK.(*guiWidget)
|
|
||||||
value := mouseH - tk.gocuiSize.h0 - 1
|
|
||||||
log.Log(NOW, "mouseUp() me.ddview.tk.gocuiSize.h1 =", tk.gocuiSize.h1)
|
|
||||||
log.Log(NOW, "mouseUp() me.ddNode.vals =", ddtk.vals)
|
|
||||||
valsLen := len(ddtk.vals)
|
|
||||||
log.Log(NOW, "mouseUp() value =", value, "valsLen =", valsLen)
|
|
||||||
log.Log(NOW, "mouseUp() me.ddNode.vals =", ddtk.vals)
|
|
||||||
if (value >= 0) && (value < valsLen) {
|
|
||||||
newZone = ddtk.vals[value]
|
|
||||||
log.Log(NOW, "mouseUp() value =", value, "newZone =", newZone)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// send the event the user selected something from the dropdown
|
|
||||||
hideDDview()
|
|
||||||
me.dropdownW.SetText(newZone)
|
|
||||||
me.myTree.SendUserEvent(me.dropdownW.node)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue