void TranslateKeyboardEvent(NSEvent e) { e.ToKeyMsg(out Msg msg, out IntPtr wParam, out IntPtr lParam); //Debug.WriteLine ("keyCode={0}, characters=\"{1}\", key='{2}', chars='{3}'", e.KeyCode, chars, key, chars); // See the comment above SendPendingWmKeyDown() if you want to ask 'what the hell is this?'. isWmKeyDownPending = e.Type == NSEventType.KeyDown && (view is MonoEditView); if (isWmKeyDownPending) { pendingWmKeyDown = new MSG { hwnd = view.Handle, message = msg, wParam = wParam, lParam = lParam } } ; else { driver.SendMessage(view.Handle, msg, wParam, lParam); } // On Windows, this would normally be done in TranslateMessage if (e.Type == NSEventType.KeyDown) // && (view is MonoEditView)) { wmCharLParam = lParam; view.InterpretKeyEvents(new[] { e }); wmCharLParam = IntPtr.Zero; } }
void TranslateKeyboardEvent(NSEvent e) { repeatCount = e.IsARepeat ? 1 + repeatCount : 0; Keys key = KeysConverter.GetKeys(e); bool isExtendedKey = ctrlDown || cmdDown || e.Characters.Length == 0 || !KeysConverter.IsChar(e.Characters[0], key) && KeysConverter.DeadKeyState == 0; ulong lp = 0; lp |= ((ulong)(uint)repeatCount); lp |= ((ulong)e.KeyCode) << 16; // OEM-dependent scanCode lp |= ((ulong)(isExtendedKey ? 1 : 0)) << 24; lp |= ((ulong)(e.IsARepeat ? 1 : 0)) << 30; IntPtr lParam = (IntPtr)lp; IntPtr wParam = (IntPtr)key; bool isSysKey = false; // altDown && !cmdDown Msg msg = isSysKey ? (e.Type == NSEventType.KeyDown ? Msg.WM_SYSKEYDOWN : Msg.WM_SYSKEYUP) : (e.Type == NSEventType.KeyDown ? Msg.WM_KEYDOWN : Msg.WM_KEYUP); //Debug.WriteLine ("keyCode={0}, characters=\"{1}\", key='{2}', chars='{3}'", e.KeyCode, chars, key, chars); // See the comment above SendPendingWmKeyDown() if you want to ask 'what the hell is this?'. isWmKeyDownPending = e.Type == NSEventType.KeyDown && (view is MonoEditView); if (isWmKeyDownPending) { pendingWmKeyDown = new MSG { hwnd = view.Handle, message = msg, wParam = wParam, lParam = lParam } } ; else { driver.SendMessage(view.Handle, msg, wParam, lParam); } // On Windows, this would normally be done in TranslateMessage if (e.Type == NSEventType.KeyDown) // && (view is MonoEditView)) { wmCharLParam = lParam; view.InterpretKeyEvents(new[] { e }); wmCharLParam = IntPtr.Zero; } }