1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #65558 from the-sink/replication-editor

Allow enter key to add properties to replication editor list
This commit is contained in:
Rémi Verschelde
2023-08-30 12:15:38 +02:00
2 changed files with 14 additions and 1 deletions

View File

@@ -256,6 +256,7 @@ ReplicationEditor::ReplicationEditor() {
np_line_edit = memnew(LineEdit);
np_line_edit->set_placeholder(":property");
np_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
np_line_edit->connect("text_submitted", callable_mp(this, &ReplicationEditor::_np_text_submitted));
hb->add_child(np_line_edit);
add_from_path_button = memnew(Button);
add_from_path_button->connect("pressed", callable_mp(this, &ReplicationEditor::_add_pressed));
@@ -292,7 +293,7 @@ ReplicationEditor::ReplicationEditor() {
vb->add_child(tree);
drop_label = memnew(Label);
drop_label->set_text(TTR("Add properties using the buttons above or\ndrag them them from the inspector and drop them here."));
drop_label->set_text(TTR("Add properties using the options above, or\ndrag them them from the inspector and drop them here."));
drop_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
drop_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
tree->add_child(drop_label);
@@ -384,6 +385,13 @@ void ReplicationEditor::_add_pressed() {
return;
}
String np_text = np_line_edit->get_text();
if (np_text.is_empty()) {
error_dialog->set_text(TTR("Property/path must not be empty."));
error_dialog->popup_centered();
return;
}
int idx = np_text.find(":");
if (idx == -1) {
np_text = ".:" + np_text;
@@ -395,6 +403,10 @@ void ReplicationEditor::_add_pressed() {
_add_sync_property(path);
}
void ReplicationEditor::_np_text_submitted(const String &p_newtext) {
_add_pressed();
}
void ReplicationEditor::_tree_item_edited() {
TreeItem *ti = tree->get_edited();
if (!ti || config.is_null()) {

View File

@@ -72,6 +72,7 @@ private:
Ref<Texture2D> _get_class_icon(const Node *p_node);
void _add_pressed();
void _np_text_submitted(const String &p_newtext);
void _tree_item_edited();
void _tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _update_checked(const NodePath &p_prop, int p_column, bool p_checked);