Skip to content

Commit

Permalink
Implement undo and redo while holding (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
Schweini07 authored Dec 22, 2020
1 parent ab583a7 commit 425b11d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,27 @@ func _input(event : InputEvent) -> void:
if get_focus_owner() is LineEdit:
get_focus_owner().release_focus()

if event.is_action_pressed("redo_secondary"): # Shift + Ctrl + Z
# The section of code below is reserved for Undo and Redo! Do not place code for Input below, but above.
if !event.is_echo(): # Checks if the action is pressed down
if event.is_action_pressed("redo_secondary"): # Done, so that "redo_secondary" hasn't
redone = true # a slight delay before it starts. The "redo" and "undo" action don't have a slight delay,
Global.current_project.undo_redo.redo() # The "redo" and "undo" action don't have a slight delay,
redone = false # because they get called as an accelerator once pressed (TopMenuContainer.gd / Line 152).
return

if event.is_action("redo"): # Ctrl + Y
redone = true
Global.current_project.undo_redo.redo()
redone = false

if event.is_action("redo_secondary"): # Shift + Ctrl + Z
redone = true
Global.current_project.undo_redo.redo()
redone = false

if event.is_action("undo") and !event.shift: # Ctrl + Z and check if shift isn't pressed
Global.current_project.undo_redo.undo() # so "undo" isn't accidentaly triggered while using "redo_secondary"


func setup_application_window_size() -> void:
if OS.get_name() == "HTML5":
Expand Down

0 comments on commit 425b11d

Please sign in to comment.