Example #1
0
        public static InputHandlerDescriptor ParseDragDescriptor(string input)
        {
            InputHandlerDescriptor retn = ParseDescriptor(input);

            retn.handlerType = ParseDragInputEventType(retn.eventName);

            return(retn);
        }
Example #2
0
        private static InputHandlerDescriptor ParseDescriptor(string input)
        {
            InputHandlerDescriptor retn = default;

            retn.eventPhase    = EventPhase.Bubble;
            retn.modifiers     = KeyboardModifiers.None;
            retn.requiresFocus = false;
            input = input.ToLower();
            int dotIndex = input.IndexOf('.');

            if (dotIndex == -1)
            {
                retn.eventName = input;
                return(retn);
            }
            else
            {
                string[] parts = input.Split(s_SplitDot, StringSplitOptions.RemoveEmptyEntries);

                retn.eventName = parts[0];

                for (int i = 1; i < parts.Length; i++)
                {
                    string part = parts[i];

                    switch (part)
                    {
                    case "focus":
                        retn.requiresFocus = true;
                        break;

                    case "capture": {
                        retn.eventPhase = EventPhase.Capture;
                        break;
                    }

                    case "shift": {
                        retn.modifiers |= KeyboardModifiers.Shift;
                        break;
                    }

                    case "ctrl":
                    case "control": {
                        retn.modifiers |= KeyboardModifiers.Control;
                        break;
                    }

                    case "cmd":
                    case "command": {
                        retn.modifiers |= KeyboardModifiers.Command;
                        break;
                    }

                    case "alt": {
                        retn.modifiers |= KeyboardModifiers.Alt;
                        break;
                    }

                    default:
                        throw new ParseException("Invalid mouse modifier: " + part + " in input string: " + input);
                    }
                }
            }

            return(retn);
        }