예제 #1
0
        // CurveEditor uses an hardcoded shortcut to execute the FrameAll action, preventing the ShortcutManager from
        // ever picking it up. We have to hijack it to ensure our code is being run when framing inline curves.
        protected override bool KeyDown(Event evt, WindowState state)
        {
            var inlineCurveEditor = SelectionManager.GetCurrentInlineEditorCurve();

            if (inlineCurveEditor == null || !inlineCurveEditor.inlineCurvesSelected)
            {
                return(false);
            }

            // Not conflicting with the hardcoded value
            if (evt.keyCode != KeyCode.A)
            {
                return(false);
            }

            var combination = ShortcutManager.instance.GetShortcutBinding(Shortcuts.Timeline.frameAll)
                              .keyCombinationSequence.ToList();

            var shortcutCombination = combination.First();
            var currentCombination  = KeyCombination.FromKeyboardInput(evt);

            // User is not actually pressing the correct key combination for FrameAll
            if (combination.Count == 1 && shortcutCombination.Equals(currentCombination))
            {
                Invoker.InvokeWithSelected <FrameAllAction>();
            }

            return(true);
        }
예제 #2
0
        public static void HandleSearchEvent(EditorWindow window, Event evt, string searchText)
        {
            if (evt.type != EventType.KeyDown)
            {
                return;
            }

            var keyCombination = KeyCombination.FromKeyboardInput(evt);

            if (shortcutBinding.keyCombinationSequence.Any(shortcutCombination => keyCombination.Equals(shortcutCombination)))
            {
                evt.Use();
                OpenSearchInContext(window, searchText, "jumpShortcut");
            }
        }
        // This callback is needed because the Animation window registers "Animation/Key Selected" as a global hotkey
        // and we want  to also react to the key.
        void GlobalEventHandler()
        {
            if (instance == null || !state.previewMode)
            {
                return;
            }

            var keyBinding = ShortcutManager.instance.GetShortcutBinding("Animation/Key Selected");

            if (keyBinding.Equals(ShortcutBinding.empty))
            {
                return;
            }

            var evtCombo = KeyCombination.FromKeyboardInput(Event.current);

            if (keyBinding.keyCombinationSequence.Contains(evtCombo))
            {
                Invoker.InvokeWithSelected <KeyAllAnimated>();
            }
        }