mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
io/key: add String methods to Modifiers and Event
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -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, "|")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user