From 7f347cc31a121a059e881d4df52add49642dcca3 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 13 Nov 2018 18:50:54 -0300 Subject: [PATCH] It is now possible to cancel on 2D polygon editor. RMB (previously close) and ESC will cancel polygon. Closes #15474 --- editor/plugins/abstract_polygon_2d_editor.cpp | 16 +++++++++++++++- editor/plugins/abstract_polygon_2d_editor.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 71a5d73b2f4..16423decc44 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -229,6 +229,18 @@ void AbstractPolygon2DEditor::_wip_changed() { } } +void AbstractPolygon2DEditor::_wip_cancel() { + + wip.clear(); + wip_active = false; + + edited_point = PosVertex(); + hover_point = Vertex(); + selected_point = Vertex(); + + canvas_item_editor->update_viewport(); +} + void AbstractPolygon2DEditor::_wip_close() { if (!wip_active) return; @@ -429,7 +441,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref &p_event) } } } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) { - _wip_close(); + _wip_cancel(); } } } @@ -510,6 +522,8 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref &p_event) } else if (wip_active && k->get_scancode() == KEY_ENTER) { _wip_close(); + } else if (wip_active && k->get_scancode() == KEY_ESCAPE) { + _wip_cancel(); } } diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h index 00634ba5b86..c03670f254b 100644 --- a/editor/plugins/abstract_polygon_2d_editor.h +++ b/editor/plugins/abstract_polygon_2d_editor.h @@ -103,6 +103,7 @@ protected: virtual void _menu_option(int p_option); void _wip_changed(); void _wip_close(); + void _wip_cancel(); bool _delete_point(const Vector2 &p_gpoint); void _notification(int p_what);