本文整理汇总了Golang中golang.org/x/mobile/event/key.Event.Direction方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.Direction方法的具体用法?Golang Event.Direction怎么用?Golang Event.Direction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golang.org/x/mobile/event/key.Event
的用法示例。
在下文中一共展示了Event.Direction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: processKey
func processKey(env *C.JNIEnv, e *C.AInputEvent) {
deviceID := C.AInputEvent_getDeviceId(e)
if deviceID == 0 {
// Software keyboard input, leaving for scribe/IME.
return
}
k := key.Event{
Rune: rune(C.getKeyRune(env, e)),
Code: convAndroidKeyCode(int32(C.AKeyEvent_getKeyCode(e))),
}
switch C.AKeyEvent_getAction(e) {
case C.AKEY_STATE_DOWN:
k.Direction = key.DirPress
case C.AKEY_STATE_UP:
k.Direction = key.DirRelease
default:
k.Direction = key.DirNone
}
// TODO(crawshaw): set Modifiers.
eventsIn <- k
}
示例2: sendKeyEvent
func sendKeyEvent(hwnd HWND, uMsg uint32, wParam, lParam uintptr) (lResult uintptr) {
e := key.Event{
Rune: readRune(uint32(wParam), uint8(lParam>>16)),
Code: convVirtualKeyCode(uint32(wParam)),
Modifiers: keyModifiers(),
}
switch uMsg {
case _WM_KEYDOWN:
const prevMask = 1 << 30
if repeat := lParam&prevMask == prevMask; repeat {
e.Direction = key.DirNone
} else {
e.Direction = key.DirPress
}
case _WM_KEYUP:
e.Direction = key.DirRelease
default:
panic(fmt.Sprintf("win32: unexpected key message: %d", uMsg))
}
KeyEvent(hwnd, e)
return 0
}