From e5c74b832be68fdbefb9c7527c2367dba1cec7a8 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 21 Aug 2014 05:37:24 -0400 Subject: Changed AreaHandler.Key() to return a boolean value indicating if the event was handled; implemented this on Windows. It does sledgehammer some edge cases I wanted to avoid, but it also avoids fussing about scrolling and focus and what not. --- redo/zz_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'redo/zz_test.go') diff --git a/redo/zz_test.go b/redo/zz_test.go index f3392ad..e8ccead 100644 --- a/redo/zz_test.go +++ b/redo/zz_test.go @@ -63,14 +63,16 @@ type testwin struct { wsmall Window } -type areaHandler struct{} +type areaHandler struct { + handled bool +} func (a *areaHandler) Paint(r image.Rectangle) *image.RGBA { i := image.NewRGBA(r) draw.Draw(i, r, &image.Uniform{color.RGBA{128,0,128,255}}, image.ZP, draw.Src) return i } func (a *areaHandler) Mouse(me MouseEvent) { fmt.Printf("%#v\n", me) } -func (a *areaHandler) Key(ke KeyEvent) { fmt.Printf("%#v %q\n", ke, ke.Key) } +func (a *areaHandler) Key(ke KeyEvent) bool { fmt.Printf("%#v %q\n", ke, ke.Key); return a.handled } func (tw *testwin) addfe() { tw.festart = NewButton("Start") @@ -169,7 +171,7 @@ func (tw *testwin) make(done chan struct{}) { tw.nt.Append("Tab 2", Space()) tw.t.Append("Tab", tw.nt) tw.t.Append("Space", Space()) - tw.a = NewArea(200, 200, &areaHandler{}) + tw.a = NewArea(200, 200, &areaHandler{false}) tw.t.Append("Area", tw.a) tw.spw = NewHorizontalStack( NewButton("hello"), @@ -233,7 +235,7 @@ func (tw *testwin) make(done chan struct{}) { NewVerticalStack( NewButton("Small"), NewButton("Small 2"), - NewArea(200, 200, &areaHandler{}))) + NewArea(200, 200, &areaHandler{true}))) tw.wsmall.Show() } } -- cgit v1.2.3