ui/key: expand documentation

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-08-11 13:09:55 +02:00
parent dce7ad2f58
commit 1a9e03bf68
+17 -1
View File
@@ -34,23 +34,37 @@ type FocusEvent struct {
Focus bool Focus bool
} }
// Event is sent when a key is pressed. For text input
// use EditEvent.
type Event struct { type Event struct {
Name rune // Name is the rune character that most closely
// match the key. For letters, the upper case form
// is used.
Name rune
// Modifiers is the set of active modifiers when
// the key was pressed.
Modifiers Modifiers Modifiers Modifiers
} }
// EditEvent is sent when text is input.
type EditEvent struct { type EditEvent struct {
Text string Text string
} }
// Modifiers
type Modifiers uint32 type Modifiers uint32
const ( const (
// ModCommand is the command modifier. On macOS
// it is the Cmd key, on other platforms the Ctrl
// key.
ModCommand Modifiers = 1 << iota ModCommand Modifiers = 1 << iota
// THe shift key.
ModShift ModShift
) )
const ( const (
// Runes for special keys.
NameLeftArrow = '←' NameLeftArrow = '←'
NameRightArrow = '→' NameRightArrow = '→'
NameUpArrow = '↑' NameUpArrow = '↑'
@@ -66,6 +80,8 @@ const (
NamePageDown = '⇟' NamePageDown = '⇟'
) )
// Contain reports whether m contains all modifiers
// in m2.
func (m Modifiers) Contain(m2 Modifiers) bool { func (m Modifiers) Contain(m2 Modifiers) bool {
return m&m2 == m2 return m&m2 == m2
} }