mirror of
https://github.com/godotengine/godot.git
synced 2025-11-02 06:31:13 +00:00
Improve Undo/Redo menu items
* Make Undo/Redo menu items disabled when clicking it does nothing.
* Context menu of `TextEdit`
* Context menu of `LineEdit`
* Editor's Scene menu
* Script editor's Edit menu and context menu (for Script and Text)
* Make editor undo/redo log messages translatable.
* Mark `UndoRedo`'s `has_{un,re}do()` methods as `const`.
* Expose `TextEdit`'s `has_{un,re}do()` to scripts since `{un,re}do()` are already available.
This commit is contained in:
parent
ca6c5cf7e6
commit
16c2d4ef22
13 changed files with 94 additions and 12 deletions
|
|
@ -1628,6 +1628,13 @@ void ScriptTextEditor::_color_changed(const Color &p_color) {
|
|||
code_editor->get_text_editor()->update();
|
||||
}
|
||||
|
||||
void ScriptTextEditor::_prepare_edit_menu() {
|
||||
const CodeEdit *tx = code_editor->get_text_editor();
|
||||
PopupMenu *popup = edit_menu->get_popup();
|
||||
popup->set_item_disabled(popup->get_item_index(EDIT_UNDO), !tx->has_undo());
|
||||
popup->set_item_disabled(popup->get_item_index(EDIT_REDO), !tx->has_redo());
|
||||
}
|
||||
|
||||
void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition, Vector2 p_pos) {
|
||||
context_menu->clear();
|
||||
context_menu->add_shortcut(ED_GET_SHORTCUT("ui_undo"), EDIT_UNDO);
|
||||
|
|
@ -1667,6 +1674,10 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p
|
|||
}
|
||||
}
|
||||
|
||||
const CodeEdit *tx = code_editor->get_text_editor();
|
||||
context_menu->set_item_disabled(context_menu->get_item_index(EDIT_UNDO), !tx->has_undo());
|
||||
context_menu->set_item_disabled(context_menu->get_item_index(EDIT_REDO), !tx->has_redo());
|
||||
|
||||
context_menu->set_position(get_global_transform().xform(p_pos));
|
||||
context_menu->set_size(Vector2(1, 1));
|
||||
context_menu->popup();
|
||||
|
|
@ -1752,6 +1763,7 @@ void ScriptTextEditor::_enable_code_editor() {
|
|||
search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
|
||||
|
||||
edit_hb->add_child(edit_menu);
|
||||
edit_menu->connect("about_to_popup", callable_mp(this, &ScriptTextEditor::_prepare_edit_menu));
|
||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_undo"), EDIT_UNDO);
|
||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_redo"), EDIT_REDO);
|
||||
edit_menu->get_popup()->add_separator();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue