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

Allow enter key to add properties to replication editor list

This commit is contained in:
the-sink
2022-09-08 21:42:09 -07:00
parent d2f76e8786
commit 8f80ebc035
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()) {