Merge pull request #93898 from KoBeWi/rundo_edo
Fix undoredo handling in some dialogs
This commit is contained in:
commit
f986a801fc
7 changed files with 66 additions and 28 deletions
|
@ -5261,6 +5261,14 @@ bool EditorNode::has_scenes_in_session() {
|
|||
return !scenes.is_empty();
|
||||
}
|
||||
|
||||
void EditorNode::undo() {
|
||||
trigger_menu_option(EDIT_UNDO, true);
|
||||
}
|
||||
|
||||
void EditorNode::redo() {
|
||||
trigger_menu_option(EDIT_REDO, true);
|
||||
}
|
||||
|
||||
bool EditorNode::ensure_main_scene(bool p_from_native) {
|
||||
pick_main_scene->set_meta("from_native", p_from_native); // Whether from play button or native run.
|
||||
String main_scene = GLOBAL_GET("application/run/main_scene");
|
||||
|
|
|
@ -916,6 +916,9 @@ public:
|
|||
|
||||
bool has_scenes_in_session();
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
int execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok = true, bool p_close_on_errors = false, String *r_output = nullptr);
|
||||
|
||||
EditorNode();
|
||||
|
|
|
@ -168,28 +168,17 @@ void EditorSettingsDialog::_notification(int p_what) {
|
|||
}
|
||||
|
||||
void EditorSettingsDialog::shortcut_input(const Ref<InputEvent> &p_event) {
|
||||
ERR_FAIL_COND(p_event.is_null());
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
|
||||
const Ref<InputEventKey> k = p_event;
|
||||
if (k.is_valid() && k->is_pressed()) {
|
||||
bool handled = false;
|
||||
|
||||
if (ED_IS_SHORTCUT("ui_undo", p_event)) {
|
||||
String action = undo_redo->get_current_action_name();
|
||||
if (!action.is_empty()) {
|
||||
EditorNode::get_log()->add_message(vformat(TTR("Undo: %s"), action), EditorLog::MSG_TYPE_EDITOR);
|
||||
}
|
||||
undo_redo->undo();
|
||||
EditorNode::get_singleton()->undo();
|
||||
handled = true;
|
||||
}
|
||||
|
||||
if (ED_IS_SHORTCUT("ui_redo", p_event)) {
|
||||
undo_redo->redo();
|
||||
String action = undo_redo->get_current_action_name();
|
||||
if (!action.is_empty()) {
|
||||
EditorNode::get_log()->add_message(vformat(TTR("Redo: %s"), action), EditorLog::MSG_TYPE_EDITOR);
|
||||
}
|
||||
EditorNode::get_singleton()->redo();
|
||||
handled = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -781,6 +781,27 @@ void AnimationLibraryEditor::_update_editor(Object *p_mixer) {
|
|||
emit_signal("update_editor", p_mixer);
|
||||
}
|
||||
|
||||
void AnimationLibraryEditor::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 AnimationLibraryEditor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_update_editor", "mixer"), &AnimationLibraryEditor::_update_editor);
|
||||
ADD_SIGNAL(MethodInfo("update_editor"));
|
||||
|
@ -788,6 +809,7 @@ void AnimationLibraryEditor::_bind_methods() {
|
|||
|
||||
AnimationLibraryEditor::AnimationLibraryEditor() {
|
||||
set_title(TTR("Edit Animation Libraries"));
|
||||
set_process_shortcut_input(true);
|
||||
|
||||
file_dialog = memnew(EditorFileDialog);
|
||||
add_child(file_dialog);
|
||||
|
|
|
@ -113,6 +113,7 @@ class AnimationLibraryEditor : public AcceptDialog {
|
|||
protected:
|
||||
void _notification(int p_what);
|
||||
void _update_editor(Object *p_mixer);
|
||||
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
|
|
|
@ -52,6 +52,31 @@
|
|||
#include "scene/gui/texture_rect.h"
|
||||
#include "scene/gui/view_panner.h"
|
||||
|
||||
class UVEditDialog : public AcceptDialog {
|
||||
GDCLASS(UVEditDialog, AcceptDialog);
|
||||
|
||||
void shortcut_input(const Ref<InputEvent> &p_event) override {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Node2D *Polygon2DEditor::_get_node() const {
|
||||
return node;
|
||||
}
|
||||
|
@ -1305,9 +1330,10 @@ Polygon2DEditor::Polygon2DEditor() {
|
|||
button_uv->connect(SceneStringName(pressed), callable_mp(this, &Polygon2DEditor::_menu_option).bind(MODE_EDIT_UV));
|
||||
|
||||
uv_mode = UV_MODE_EDIT_POINT;
|
||||
uv_edit = memnew(AcceptDialog);
|
||||
add_child(uv_edit);
|
||||
uv_edit = memnew(UVEditDialog);
|
||||
uv_edit->set_title(TTR("Polygon 2D UV Editor"));
|
||||
uv_edit->set_process_shortcut_input(true);
|
||||
add_child(uv_edit);
|
||||
uv_edit->connect(SceneStringName(confirmed), callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
|
||||
uv_edit->connect("canceled", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
|
||||
|
||||
|
|
|
@ -235,28 +235,17 @@ void ProjectSettingsEditor::_select_type(Variant::Type p_type) {
|
|||
}
|
||||
|
||||
void ProjectSettingsEditor::shortcut_input(const Ref<InputEvent> &p_event) {
|
||||
ERR_FAIL_COND(p_event.is_null());
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
|
||||
const Ref<InputEventKey> k = p_event;
|
||||
if (k.is_valid() && k->is_pressed()) {
|
||||
bool handled = false;
|
||||
|
||||
if (ED_IS_SHORTCUT("ui_undo", p_event)) {
|
||||
String action = undo_redo->get_current_action_name();
|
||||
if (!action.is_empty()) {
|
||||
EditorNode::get_log()->add_message(vformat(TTR("Undo: %s"), action), EditorLog::MSG_TYPE_EDITOR);
|
||||
}
|
||||
undo_redo->undo();
|
||||
EditorNode::get_singleton()->undo();
|
||||
handled = true;
|
||||
}
|
||||
|
||||
if (ED_IS_SHORTCUT("ui_redo", p_event)) {
|
||||
undo_redo->redo();
|
||||
String action = undo_redo->get_current_action_name();
|
||||
if (!action.is_empty()) {
|
||||
EditorNode::get_log()->add_message(vformat(TTR("Redo: %s"), action), EditorLog::MSG_TYPE_EDITOR);
|
||||
}
|
||||
EditorNode::get_singleton()->redo();
|
||||
handled = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue