Skip to content

Commit

Permalink
correctly document the resize event
Browse files Browse the repository at this point in the history
  • Loading branch information
faiface committed May 6, 2019
1 parent d80d49a commit 875b12b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ Examples of `Event` strings are: `"wi/close"`, `"mo/move/104/320"`, `"kb/type/71

```go
switch {
case event.Matches("resize/%d/%d", &w, &h):
// environment resized to (w, h)
case event.Matches("resize/%d/%d/%d/%d", &x0, &y0, &x1, &y1):
// environment resized to (x0, y0, x1, y1)
case event.Matches("wi/close"):
// window closed
case event.Matches("mo/move/%d/%d", &x, &y):
Expand All @@ -116,7 +116,7 @@ case event.Matches("kb/repeat/%s", &key):

This shows all the possible events that a window can produce. You can find a little more info (especially on the keys) [here in GoDoc](https://godoc.org/github.com/faiface/gui/win#Win).

The `"resize"` event is not prefixed with `"wi/"`, because it's not specific to windows.
The `"resize"` event is not prefixed with `"wi/"`, because it's not specific to windows. It is also guaranteed to be the first event produced by any `Env`.

You can also match only specific buttons/keys, or ignore them:

Expand Down
2 changes: 2 additions & 0 deletions env.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
// supplied draw.Image, which is the drawing area of the Env and returns a rectangle
// covering the whole part of the image that got changed.
//
// An Env guarantees to produce a "resize/<x0>/<y0>/<x1>/<y1>" event as its first event.
//
// The Events() channel must be unlimited in capacity. Use MakeEventsChan() to create
// a channel of events with an unlimited capacity.
//
Expand Down

0 comments on commit 875b12b

Please sign in to comment.