Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow enter key to add properties to replication editor list #65558

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion modules/multiplayer/editor/replication_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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()) {
Expand Down
1 change: 1 addition & 0 deletions modules/multiplayer/editor/replication_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ReplicationEditor : public VBoxContainer {
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);
Expand Down
Loading