- Home /
Can my EditorWindow intercept Undo Redo Keyboard commands?
Is it possible to Intercept/Prevent Ctrl + Z, or Ctrl + Y from being executed by the Scene view if my EditorWindow has the Focus? :)
Ex:
             bool doesThisWinHaveFocus = EditorWindow.focusedWindow == win;
             bool wasUndoRedoPerformed = Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed";
             if( wasUndoRedoPerformed && doesThisWinHaveFocus == true )
             {
                 Event.current.Use();
             }
     
             if( Event.current.type == EventType.keyUp && Event.current.control && Event.current.keyCode == KeyCode.Z )
             {
                 bPerformUndo = true;
                 Event.current.Use();
             }
             else if( Event.current.type == EventType.keyUp && Event.current.control && Event.current.keyCode == KeyCode.Y )
             {
                 bPerformRedo = true;
                 Event.current.Use();
             }
 
Thanks for any help. :)
$$anonymous$$ay I ask what you're trying to do? why do you want to intercept undo/redo?
For starters, I don't think you could intercept it by checking for "UndoRedoPerformed" because as the name suggests, the operation has been performed.
When i read this page, http://docs.unity3d.com/Documentation/ScriptReference/EventType.ValidateCommand.html, i'm under the impression that it doesnt run until EventType.ExecuteCommand
"why do you want to intercept undo/redo?"
I have a Custom Undo/Redo list i added myself and want to take over the use of Control + Z and Control + Y. The user might be Undoing important changes in the Scene and not know it.
I just know someone will suggest that if i have my heart set on using Ctrl + Z/Y that i should just call Undo.PerformRedo/Undo.PerformUndo after so it can redo/undo any unwanted changes in the Scene. ;)
Ehhh... there must be a better way!?! Right?!? :/
Your answer
 
 
             Follow this Question
Related Questions
Catch a unity undo/redo event. 2 Answers
Custom data for undo/redo action? 0 Answers
unity not undoing transform changes? 1 Answer
How to record hideFlags for Undo/Redo 0 Answers
Editor undo generic collection C# 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                