event/key: make Event implement fmt.Stringer.

Change-Id: I453bed283767e0adf5efd271b329a469c0073d69
Reviewed-on: https://go-review.googlesource.com/13733
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Nigel Tao 2015-08-20 15:14:01 +10:00
parent ab223cffc9
commit 3a0fcd575e
1 changed files with 7 additions and 0 deletions

View File

@ -54,6 +54,13 @@ type Event struct {
// TODO: add a time.Time?
}
func (e Event) String() string {
if e.Rune >= 0 {
return fmt.Sprintf("key.Event{%q (%v), %v, %v}", e.Rune, e.Code, e.Modifiers, e.Direction)
}
return fmt.Sprintf("key.Event{(%v), %v, %v}", e.Code, e.Modifiers, e.Direction)
}
// Direction is the direction of the key event.
type Direction uint8