diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-12 22:58:23 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-12 22:58:23 -0400 |
| commit | 0a4dfbbae14accf21269e90e77d5b980e3dc2dc7 (patch) | |
| tree | dc46529192504627bba9b9716d96041c72c0db08 | |
| parent | 503364af519baae1ea72c6ce90981622db8ea7f8 (diff) | |
Added a new method to AreaHandler, Defocuses(), for navigation events.
| -rw-r--r-- | redo/area.go | 4 | ||||
| -rw-r--r-- | redo/zz_test.go | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/redo/area.go b/redo/area.go index 2ce7d5c..190fa10 100644 --- a/redo/area.go +++ b/redo/area.go @@ -76,6 +76,10 @@ type AreaHandler interface { // See KeyEvent for details. // After handling the key event, package ui will decide whether to perform platform-dependent event chain continuation based on that platform's designated action (so it is not possible to override global key events, such as Alt-Tab, this way). Key(e KeyEvent) + + // Defocuses is called when package ui needs to tell the OS if the Area should stop accepting focus. + // When and how often Defocuses is called is implementation-defined. + Defocuses() bool } // MouseEvent contains all the information for a mous event sent by Area.Mouse. diff --git a/redo/zz_test.go b/redo/zz_test.go index 9747700..529c43b 100644 --- a/redo/zz_test.go +++ b/redo/zz_test.go @@ -16,6 +16,7 @@ import ( var closeOnClick = flag.Bool("close", false, "close on click") var smallWindow = flag.Bool("small", false, "open a small window (test Mac OS X initial control sizing)") +var defocuses = flag.Bool("defocuses", false, "if the Area in the small window (see -small) should defocus") type dtype struct { Name string @@ -47,7 +48,7 @@ type testwin struct { wsmall Window } -type areaHandler struct{} +type areaHandler struct{defocuses 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) @@ -55,6 +56,7 @@ func (a *areaHandler) Paint(r image.Rectangle) *image.RGBA { } 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) Defocuses() bool { return a.defocuses } func (tw *testwin) make(done chan struct{}) { tw.t = NewTab() @@ -139,7 +141,7 @@ func (tw *testwin) make(done chan struct{}) { NewVerticalStack( NewButton("Small"), NewButton("Small"), - NewArea(200, 200, &areaHandler{}))) + NewArea(200, 200, &areaHandler{*defocuses}))) tw.wsmall.Show() } } |
