summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eventBindings.go4
-rw-r--r--eventMouse.go68
-rw-r--r--eventMouseClick.go8
-rw-r--r--eventMouseDrag.go8
-rw-r--r--init.go6
-rw-r--r--textbox.go2
-rw-r--r--window.go21
7 files changed, 63 insertions, 54 deletions
diff --git a/eventBindings.go b/eventBindings.go
index 65296a7..c9a4a08 100644
--- a/eventBindings.go
+++ b/eventBindings.go
@@ -81,7 +81,7 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error {
win := findWindowUnderMouse()
if win != nil {
win.dumpWidget("found() win. redrawing window:")
- win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0)
+ win.makeWindowActive()
}
return nil
@@ -119,8 +119,6 @@ func tabCycleWindows(g *gocui.Gui, v *gocui.View) error {
return nil
}
tk.makeWindowActive()
- tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
- setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
return nil
}
diff --git a/eventMouse.go b/eventMouse.go
index 05880a8..935f2b5 100644
--- a/eventMouse.go
+++ b/eventMouse.go
@@ -110,41 +110,47 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
log.Info("never found textbox at", w, h)
return nil
}
-
// figre out what window this is
- tk := findWindowUnderMouse()
- if tk == nil {
+ win := findWindowUnderMouse()
+ if win == nil {
log.Info("mouseDown() nothing to click on at", w, h)
return nil
}
- tk.makeWindowActive()
- // log.Info("SENDING mouseDown() to findWindowUnderMouse()")
- if tk.node.WidgetType == widget.Window {
- // check to see if this is a direct click on a widget
- for _, tk := range tk.findByXYreal(w, h) {
- // tk.dumpWidget("mouseDown()")
- if tk.node.WidgetType == widget.Button {
- // log.Info("SENDING CLICK TO Button")
- tk.doWidgetClick(w, h)
- return nil
- }
- if tk.node.WidgetType == widget.Checkbox {
- // log.Info("SENDING CLICK TO Checkbox")
- tk.doWidgetClick(w, h)
- return nil
- }
- if tk.node.WidgetType == widget.Dropdown {
- // log.Info("SENDING CLICK TO Dropdown")
- tk.doWidgetClick(w, h)
- return nil
- }
- if tk.node.WidgetType == widget.Textbox {
- // log.Info("SENDING CLICK TO Textbox")
- tk.doWidgetClick(w, h)
- return nil
+ return nil
+ // me.mouse.currentDrag = tk
+
+ /*
+ if !tk.isWindowActive() {
+ tk.makeWindowActive()
+ return nil
+ }
+
+ // log.Info("SENDING mouseDown() to findWindowUnderMouse()")
+ if tk.node.WidgetType == widget.Window {
+ // check to see if this is a direct click on a widget
+ for _, tk := range tk.findByXYreal(w, h) {
+ // tk.dumpWidget("mouseDown()")
+ if tk.node.WidgetType == widget.Button {
+ // log.Info("SENDING CLICK TO Button")
+ tk.doWidgetClick(w, h)
+ return nil
+ }
+ if tk.node.WidgetType == widget.Checkbox {
+ // log.Info("SENDING CLICK TO Checkbox")
+ tk.doWidgetClick(w, h)
+ return nil
+ }
+ if tk.node.WidgetType == widget.Dropdown {
+ // log.Info("SENDING CLICK TO Dropdown")
+ tk.doWidgetClick(w, h)
+ return nil
+ }
+ if tk.node.WidgetType == widget.Textbox {
+ // log.Info("SENDING CLICK TO Textbox")
+ tk.doWidgetClick(w, h)
+ return nil
+ }
}
}
- }
- me.mouse.currentDrag = tk
- return nil
+ */
}
diff --git a/eventMouseClick.go b/eventMouseClick.go
index 9e4aa1e..79809b0 100644
--- a/eventMouseClick.go
+++ b/eventMouseClick.go
@@ -115,9 +115,7 @@ func doMouseClick(w int, h int) {
return
}
// log.Info("you clicked on a window, but not any widgets. check for title / close window here", win.cuiName)
- win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0)
- me.stdout.outputOnTop = false
- setThingsOnTop()
+ win.makeWindowActive()
return
}
@@ -154,9 +152,7 @@ func doMouseDoubleClick(w int, h int) {
for _, tk := range findByXY(w, h) {
if tk.node.WidgetType == widget.Window {
- tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
- me.stdout.outputOnTop = false
- setThingsOnTop()
+ tk.makeWindowActive()
return
}
diff --git a/eventMouseDrag.go b/eventMouseDrag.go
index c2625e1..c52867b 100644
--- a/eventMouseDrag.go
+++ b/eventMouseDrag.go
@@ -143,11 +143,9 @@ func (tk *guiWidget) moveNew() {
// compute the new location based off how far the mouse has moved
// since the mouse button was pressed down
- newW := tk.lastW + w - me.mouse.downW
- newH := tk.lastH + h - me.mouse.downH
- tk.redrawWindow(newW, newH)
-
- setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
+ tk.gocuiSize.w0 = tk.lastW + w - me.mouse.downW
+ tk.gocuiSize.h0 = tk.lastH + h - me.mouse.downH
+ tk.makeWindowActive()
return
}
if tk.node.WidgetType == widget.Flag {
diff --git a/init.go b/init.go
index 195f11b..8e7d265 100644
--- a/init.go
+++ b/init.go
@@ -306,12 +306,6 @@ func newWindowTrigger() {
relocateStdoutOffscreen()
}
tk.makeWindowActive()
- // place the new window relative to the mouse
- tk.redrawWindow(me.mouse.downW+8, me.mouse.downH-2)
- // tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
-
- setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
- // log.Log(NOW, "newWindowTrigger() after sleep")
}
}
}
diff --git a/textbox.go b/textbox.go
index 5799a3d..86b156f 100644
--- a/textbox.go
+++ b/textbox.go
@@ -118,6 +118,6 @@ func textboxClosed() {
me.textbox.callerTK.Size()
me.textbox.callerTK.placeWidgets(tk.gocuiSize.w0-4, tk.gocuiSize.h0-4)
// tk.dumpWidget("resize:" + tk.String())
- win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0)
+ win.makeWindowActive()
}
}
diff --git a/window.go b/window.go
index b152c62..e62d0e7 100644
--- a/window.go
+++ b/window.go
@@ -115,8 +115,7 @@ func redoWindows(nextW int, nextH int) {
// tk.dumpWidget(fmt.Sprintf("redoWindowsS (%d,%d)", nextW, nextH))
if tk.window.wasDragged {
// don't move windows around the user has dragged to a certain location
- tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
- setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
+ tk.makeWindowActive()
} else {
w, _ := me.baseGui.Size()
if nextW > w-20 {
@@ -175,12 +174,27 @@ func (win *guiWidget) addWindowFrame(wId int) *tree.Node {
return n
}
+func (tk *guiWidget) isWindowActive() bool {
+ if !(tk.node.WidgetType == widget.Window || tk.node.WidgetType == widget.Stdout) {
+ // only allow Window or the Stdout widgets to be made active
+ return false
+ }
+ return tk.window.active
+}
+
+// always redraws at the corner of the gocuiSize box
func (tk *guiWidget) makeWindowActive() {
if !(tk.node.WidgetType == widget.Window || tk.node.WidgetType == widget.Stdout) {
// only allow Window or the Stdout widgets to be made active
return
}
+ if tk.node.WidgetType == widget.Stdout {
+ me.stdout.outputOnTop = true
+ } else {
+ // me.stdout.outputOnTop = false // ?
+ }
+
// disable and increment all the windows
for _, tk := range me.allwin {
tk.window.order += 1
@@ -193,6 +207,9 @@ func (tk *guiWidget) makeWindowActive() {
tk.window.active = true
tk.window.order = 0
+ tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
+ setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
+
/*
// print out the window list
for _, tk := range me.allwin {