Exemplo n.º 1
0
        internal static void ToKeyMsg(this NSEvent e, out Msg msg, out IntPtr wParam, out IntPtr lParam)
        {
            var key           = KeysConverter.GetKeys(e);
            var isExtendedKey = XplatUICocoa.IsCtrlDown || XplatUICocoa.IsCmdDown || e.Characters.Length == 0 || !KeysConverter.IsChar(e.Characters[0], key) && KeysConverter.DeadKeyState == 0;

            ulong lp = 0;

            lp    |= e.IsARepeat ? 1ul : 0ul;
            lp    |= ((ulong)e.KeyCode) << 16;          // OEM-dependent scanCode
            lp    |= (isExtendedKey ? 1ul : 0ul) << 24;
            lp    |= (e.IsARepeat ? 1ul : 0ul) << 30;
            lParam = (IntPtr)lp;
            wParam = (IntPtr)key;

            var isSysKey = false;            // altDown && !cmdDown

            msg = isSysKey ? (e.Type == NSEventType.KeyDown ? Msg.WM_SYSKEYDOWN : Msg.WM_SYSKEYUP) : (e.Type == NSEventType.KeyDown ? Msg.WM_KEYDOWN : Msg.WM_KEYUP);
        }