app/internal/window: implement key.Press and key.Release on macOS

Update key.State documentation and add State.String while here. Also
update Event.String to include State.

Signed-off-by: Raffaele Sena <raff367@gmail.com>
This commit is contained in:
Raffaele Sena
2020-11-20 13:46:24 -08:00
committed by Elias Naur
parent e195309d55
commit 8a3ff4abcb
3 changed files with 25 additions and 4 deletions
+14 -2
View File
@@ -10,6 +10,7 @@ events.
package key
import (
"fmt"
"strings"
"gioui.org/internal/opconst"
@@ -64,7 +65,7 @@ const (
// Release is the state of a key that has been released.
//
// Note: release events are only implemented on the following platforms:
// Linux, Windows, WebAssembly.
// macOS, Linux, Windows, WebAssembly.
Release
)
@@ -129,7 +130,7 @@ func (Event) ImplementsEvent() {}
func (FocusEvent) ImplementsEvent() {}
func (e Event) String() string {
return "{" + string(e.Name) + " " + e.Modifiers.String() + "}"
return fmt.Sprintf("%v %v %v}", e.Name, e.Modifiers, e.State)
}
func (m Modifiers) String() string {
@@ -151,3 +152,14 @@ func (m Modifiers) String() string {
}
return strings.Join(strs, "|")
}
func (s State) String() string {
switch s {
case Press:
return "Press"
case Release:
return "Release"
default:
panic("invalid State")
}
}