Пример #1
0
        public override void KeyDown(NSEvent theEvent)
        {
            var key = (Key)MacKeyMap.GetKey((MacKeyCode)theEvent.KeyCode);

            if (!theEvent.IsARepeat)
            {
                input.SetKeyState(key, true);
                if ((input.GetModifiers() & Modifiers.Win) != 0)
                {
                    // There is no KeyUp event if the Command key is pressed down, so unpress the key immediately.
                    input.SetKeyState(key, false);
                }
            }
            if ((input.GetModifiers() & (Modifiers.Control | Modifiers.Alt | Modifiers.Win)) != 0)
            {
                return;
            }
            foreach (var c in theEvent.Characters)
            {
                // Imitation of original OpenTK backspace bug.
                if (c == (char)127)
                {
                    input.TextInput += '\b';
                    continue;
                }
                if (Enum.IsDefined(typeof(NSFunctionKey), (ulong)c))
                {
                    continue;
                }
                input.TextInput += c;
            }
        }
Пример #2
0
        public override void KeyUp(NSEvent theEvent)
        {
            var key = (Key)MacKeyMap.GetKey((MacKeyCode)theEvent.KeyCode);

            input.SetKeyState(key, false);
        }