Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undo redo for the texture region editor #99471

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions editor/plugins/texture_region_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,12 +1107,34 @@ Vector2 TextureRegionEditor::snap_point(Vector2 p_target) const {
return p_target;
}

void TextureRegionEditor::shortcut_input(const Ref<InputEvent> &p_event) {
const Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed()) {
bool handled = false;

if (ED_IS_SHORTCUT("ui_undo", p_event)) {
EditorNode::get_singleton()->undo();
handled = true;
}

if (ED_IS_SHORTCUT("ui_redo", p_event)) {
EditorNode::get_singleton()->redo();
handled = true;
}

if (handled) {
set_input_as_handled();
}
}
}

void TextureRegionEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_rect"), &TextureRegionEditor::_update_rect);
}

TextureRegionEditor::TextureRegionEditor() {
set_title(TTR("Region Editor"));
set_process_shortcut_input(true);
set_ok_button_text(TTR("Close"));

// A power-of-two value works better as a default grid size.
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/texture_region_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class TextureRegionEditor : public AcceptDialog {

protected:
void _notification(int p_what);
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
static void _bind_methods();

void _texture_preview_draw();
Expand Down