From 71731a613c7aff12b8331ae4395584e5f96309ea Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 10 Oct 2019 11:57:13 +0200 Subject: [PATCH] io/key: add String methods to Modifiers and Event Signed-off-by: Elias Naur --- io/key/key.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/io/key/key.go b/io/key/key.go index e020d8c4..1e32f281 100644 --- a/io/key/key.go +++ b/io/key/key.go @@ -10,6 +10,8 @@ events. package key import ( + "strings" + "gioui.org/internal/opconst" "gioui.org/io/event" "gioui.org/op" @@ -104,3 +106,18 @@ func (h HideInputOp) Add(o *op.Ops) { func (EditEvent) ImplementsEvent() {} func (Event) ImplementsEvent() {} func (FocusEvent) ImplementsEvent() {} + +func (e Event) String() string { + return "{" + string(e.Name) + " " + e.Modifiers.String() + "}" +} + +func (m Modifiers) String() string { + var strs []string + if m.Contain(ModCommand) { + strs = append(strs, "ModCommand") + } + if m.Contain(ModShift) { + strs = append(strs, "ModShift") + } + return strings.Join(strs, "|") +}