ui/key: rename ChordEvent to just Event

Event is like pointer.Event and we don't want the stuttering of
key.KeyEvent.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-08-11 12:49:23 +02:00
parent 2a41ff9a59
commit 340fff9814
9 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ func (q *Router) Add(e input.Event) bool {
switch e := e.(type) { switch e := e.(type) {
case pointer.Event: case pointer.Event:
q.pqueue.Push(e, &q.handlers) q.pqueue.Push(e, &q.handlers)
case key.EditEvent, key.ChordEvent, key.FocusEvent: case key.EditEvent, key.Event, key.FocusEvent:
q.kqueue.Push(e, &q.handlers) q.kqueue.Push(e, &q.handlers)
} }
return q.handlers.Updated() return q.handlers.Updated()
+1 -1
View File
@@ -365,7 +365,7 @@ func convertKeyCode(code C.jint) (rune, bool) {
func onKeyEvent(env *C.JNIEnv, class C.jclass, handle C.jlong, keyCode, r C.jint, t C.jlong) { func onKeyEvent(env *C.JNIEnv, class C.jclass, handle C.jlong, keyCode, r C.jint, t C.jlong) {
w := views[handle] w := views[handle]
if n, ok := convertKeyCode(keyCode); ok { if n, ok := convertKeyCode(keyCode); ok {
w.event(key.ChordEvent{Name: n}) w.event(key.Event{Name: n})
} }
if r != 0 { if r != 0 {
w.event(key.EditEvent{Text: string(rune(r))}) w.event(key.EditEvent{Text: string(rune(r))})
+1 -1
View File
@@ -202,7 +202,7 @@ func (w *window) setAnimating(anim bool) {
} }
func (w *window) onKeyCommand(name rune) { func (w *window) onKeyCommand(name rune) {
w.w.event(key.ChordEvent{ w.w.event(key.Event{
Name: name, Name: name,
}) })
} }
+1 -1
View File
@@ -208,7 +208,7 @@ func (w *window) focus() {
func (w *window) keyEvent(e js.Value) { func (w *window) keyEvent(e js.Value) {
k := e.Get("key").String() k := e.Get("key").String()
if n, ok := translateKey(k); ok { if n, ok := translateKey(k); ok {
cmd := key.ChordEvent{Name: n} cmd := key.Event{Name: n}
if e.Call("getModifierState", "Control").Bool() { if e.Call("getModifierState", "Control").Bool() {
cmd.Modifiers |= key.ModCommand cmd.Modifiers |= key.ModCommand
} }
+1 -1
View File
@@ -127,7 +127,7 @@ func gio_onKeys(view C.CFTypeRef, cstr *C.char, ti C.double, mods C.NSUInteger)
w := views[view] w := views[view]
for _, k := range str { for _, k := range str {
if n, ok := convertKey(k); ok { if n, ok := convertKey(k); ok {
w.w.event(key.ChordEvent{Name: n, Modifiers: kmods}) w.w.event(key.Event{Name: n, Modifiers: kmods})
} }
} }
}) })
+1 -1
View File
@@ -856,7 +856,7 @@ func (w *window) dispatchKey(keyCode C.uint32_t) {
} }
sym := C.xkb_state_key_get_one_sym(conn.xkbState, C.xkb_keycode_t(keyCode)) sym := C.xkb_state_key_get_one_sym(conn.xkbState, C.xkb_keycode_t(keyCode))
if n, ok := convertKeysym(sym); ok { if n, ok := convertKeysym(sym); ok {
cmd := key.ChordEvent{Name: n} cmd := key.Event{Name: n}
if C.xkb_state_mod_name_is_active(conn.xkbState, (*C.char)(unsafe.Pointer(&_XKB_MOD_NAME_CTRL[0])), C.XKB_STATE_MODS_EFFECTIVE) == 1 { if C.xkb_state_mod_name_is_active(conn.xkbState, (*C.char)(unsafe.Pointer(&_XKB_MOD_NAME_CTRL[0])), C.XKB_STATE_MODS_EFFECTIVE) == 1 {
cmd.Modifiers |= key.ModCommand cmd.Modifiers |= key.ModCommand
} }
+1 -1
View File
@@ -269,7 +269,7 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
return 1 return 1
case _WM_KEYDOWN, _WM_SYSKEYDOWN: case _WM_KEYDOWN, _WM_SYSKEYDOWN:
if n, ok := convertKeyCode(wParam); ok { if n, ok := convertKeyCode(wParam); ok {
cmd := key.ChordEvent{Name: n} cmd := key.Event{Name: n}
if getKeyState(_VK_CONTROL)&0x1000 != 0 { if getKeyState(_VK_CONTROL)&0x1000 != 0 {
cmd.Modifiers |= key.ModCommand cmd.Modifiers |= key.ModCommand
} }
+2 -2
View File
@@ -34,7 +34,7 @@ type FocusEvent struct {
Focus bool Focus bool
} }
type ChordEvent struct { type Event struct {
Name rune Name rune
Modifiers Modifiers Modifiers Modifiers
} }
@@ -86,5 +86,5 @@ func (h HideInputOp) Add(o *ui.Ops) {
} }
func (EditEvent) ImplementsEvent() {} func (EditEvent) ImplementsEvent() {}
func (ChordEvent) ImplementsEvent() {} func (Event) ImplementsEvent() {}
func (FocusEvent) ImplementsEvent() {} func (FocusEvent) ImplementsEvent() {}
+3 -3
View File
@@ -14,8 +14,8 @@ import (
"gioui.org/ui/input" "gioui.org/ui/input"
"gioui.org/ui/key" "gioui.org/ui/key"
"gioui.org/ui/layout" "gioui.org/ui/layout"
"gioui.org/ui/pointer"
"gioui.org/ui/paint" "gioui.org/ui/paint"
"gioui.org/ui/pointer"
"golang.org/x/image/math/fixed" "golang.org/x/image/math/fixed"
) )
@@ -118,7 +118,7 @@ func (e *Editor) Next(cfg ui.Config, queue input.Queue) (EditorEvent, bool) {
switch ke := ke.(type) { switch ke := ke.(type) {
case key.FocusEvent: case key.FocusEvent:
e.focused = ke.Focus e.focused = ke.Focus
case key.ChordEvent: case key.Event:
if !e.focused { if !e.focused {
break break
} }
@@ -559,7 +559,7 @@ func (e *Editor) scrollToCaret(cfg ui.Config) {
} }
} }
func (e *Editor) command(k key.ChordEvent) bool { func (e *Editor) command(k key.Event) bool {
switch k.Name { switch k.Name {
case key.NameReturn, key.NameEnter: case key.NameReturn, key.NameEnter:
e.append("\n") e.append("\n")