From ab6e7121e47e7339822aa3e0180285b2a1c38c7c Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 27 Mar 2014 20:31:23 -0400 Subject: Added a flag to AreaHandler.Key()/Mouse() to indicate that a repaint is needed after that event has been handled. (Having Repaint() as a method deadlocked for the same reason resizing deadlocked before.) --- test/kbtest.go | 10 ++++++---- test/main.go | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/kbtest.go b/test/kbtest.go index 0a21954..d6fa7c1 100644 --- a/test/kbtest.go +++ b/test/kbtest.go @@ -34,7 +34,9 @@ func (a *keyboardArea) Paint(cliprect image.Rectangle) *image.NRGBA { return a.kbd.SubImage(cliprect).(*image.NRGBA) } -func (a *keyboardArea) Mouse(MouseEvent) {} +func (a *keyboardArea) Mouse(MouseEvent) (repaint bool) { + return false +} func markkey(dest *image.NRGBA, keypt image.Point, m Modifiers) { xr := keyrect(m).Add(keypt) @@ -42,7 +44,7 @@ func markkey(dest *image.NRGBA, keypt image.Point, m Modifiers) { draw.Draw(dest, xr, xi, image.ZP, draw.Over) } -func (a *keyboardArea) Key(e KeyEvent) bool { +func (a *keyboardArea) Key(e KeyEvent) (handled bool, repaint bool) { a.lock.Lock() defer a.lock.Unlock() @@ -68,9 +70,9 @@ func (a *keyboardArea) Key(e KeyEvent) bool { // markkey(a.kbd, modpoints[Super], m &^ Super) // } default: - return false + return false, false } - return true + return true, true } var doKeyboard = flag.Bool("kb", false, "run keyboard test") diff --git a/test/main.go b/test/main.go index 60108ab..1e2b465 100644 --- a/test/main.go +++ b/test/main.go @@ -131,12 +131,13 @@ func (a *areaHandler) Paint(rect image.Rectangle) *image.NRGBA { */ return a.img.SubImage(rect).(*image.NRGBA) } -func (a *areaHandler) Mouse(e MouseEvent) { +func (a *areaHandler) Mouse(e MouseEvent) bool { fmt.Printf("%#v\n", e) + return false } -func (a *areaHandler) Key(e KeyEvent) bool { +func (a *areaHandler) Key(e KeyEvent) (bool, bool) { fmt.Printf("%#v\n", e) - return false + return false, false } var doArea = flag.Bool("area", false, "run area test instead (overrides -kb)") -- cgit v1.2.3