diff options
| -rw-r--r-- | gui/widget/input.go | 7 | ||||
| -rw-r--r-- | gui/widget/output.go | 5 |
2 files changed, 5 insertions, 7 deletions
diff --git a/gui/widget/input.go b/gui/widget/input.go index 1e15da9..7d5f809 100644 --- a/gui/widget/input.go +++ b/gui/widget/input.go @@ -18,25 +18,24 @@ func Input(val chan<- uint, r image.Rectangle, focus FocusSlave, env gui.Env, wg text := "0" focused := false env.Draw() <- inputDraw(text, focused, r) -Loop: for { select { case _, ok := <-focus.gain: if !ok { - break Loop + return } focused = true env.Draw() <- inputDraw(text, focused, r) case dir, ok := <-focus.lose: if !ok { - break Loop + return } focus.yield <- dir focused = false env.Draw() <- inputDraw(text, focused, r) case event, ok := <-env.Events(): if !ok { - break Loop + return } switch event := event.(type) { case win.WiFocus: diff --git a/gui/widget/output.go b/gui/widget/output.go index 16aacca..8bd25b1 100644 --- a/gui/widget/output.go +++ b/gui/widget/output.go @@ -17,14 +17,13 @@ func Output(val <-chan float64, r image.Rectangle, env gui.Env, wg *sync.WaitGro var v float64 = 0.0 env.Draw() <- outputDraw(v, r) -Loop: for { select { case v = <-val: env.Draw() <- outputDraw(v, r) case event, ok := <-env.Events(): - if !ok { // channel closed - break Loop + if !ok { + return } if event, ok := event.(win.WiFocus); ok && event.Focused { env.Draw() <- outputDraw(v, r) |