Use InputMap actions consistently across all LineEdit's that filter an underlying Tree or ItemList.

- Instead of checking for Key::UP, Key::DOWN, Key::PAGEUP, Key::PAGEDOWN etc., we rather check for the action like 'ui_up' or 'ui_down'.
- Also use AcceptDialog's 'register_text_enter' functionality to consistently close a dialog when ENTER is pressed while the LineEdit has focus (instead of redirecting ENTER keys to e.g. the underlying Tree).
- Unify the LineEdit filter behavior for the SceneTreeDialog and corresponding usages
- Improve OK Button disablement (something should be selected)
This commit is contained in:
Marius Hanl 2024-08-31 19:23:34 +02:00
parent 61598c5c88
commit 74f64aaf98
23 changed files with 140 additions and 205 deletions

View File

@ -7178,24 +7178,6 @@ void AnimationTrackEditor::_pick_track_select_recursive(TreeItem *p_item, const
} }
} }
void AnimationTrackEditor::_pick_track_filter_input(const Ref<InputEvent> &p_ie) {
Ref<InputEventKey> k = p_ie;
if (k.is_valid()) {
switch (k->get_keycode()) {
case Key::UP:
case Key::DOWN:
case Key::PAGEUP:
case Key::PAGEDOWN: {
pick_track->get_scene_tree()->get_scene_tree()->gui_input(k);
pick_track->get_filter_line_edit()->accept_event();
} break;
default:
break;
}
}
}
AnimationTrackEditor::AnimationTrackEditor() { AnimationTrackEditor::AnimationTrackEditor() {
main_panel = memnew(PanelContainer); main_panel = memnew(PanelContainer);
main_panel->set_focus_mode(FOCUS_ALL); // Allow panel to have focus so that shortcuts work as expected. main_panel->set_focus_mode(FOCUS_ALL); // Allow panel to have focus so that shortcuts work as expected.
@ -7413,11 +7395,9 @@ AnimationTrackEditor::AnimationTrackEditor() {
pick_track = memnew(SceneTreeDialog); pick_track = memnew(SceneTreeDialog);
add_child(pick_track); add_child(pick_track);
pick_track->register_text_enter(pick_track->get_filter_line_edit());
pick_track->set_title(TTR("Pick a node to animate:")); pick_track->set_title(TTR("Pick a node to animate:"));
pick_track->connect("selected", callable_mp(this, &AnimationTrackEditor::_new_track_node_selected)); pick_track->connect("selected", callable_mp(this, &AnimationTrackEditor::_new_track_node_selected));
pick_track->get_filter_line_edit()->connect(SceneStringName(text_changed), callable_mp(this, &AnimationTrackEditor::_pick_track_filter_text_changed)); pick_track->get_filter_line_edit()->connect(SceneStringName(text_changed), callable_mp(this, &AnimationTrackEditor::_pick_track_filter_text_changed));
pick_track->get_filter_line_edit()->connect(SceneStringName(gui_input), callable_mp(this, &AnimationTrackEditor::_pick_track_filter_input));
prop_selector = memnew(PropertySelector); prop_selector = memnew(PropertySelector);
add_child(prop_selector); add_child(prop_selector);

View File

@ -649,7 +649,6 @@ class AnimationTrackEditor : public VBoxContainer {
void _pick_track_filter_text_changed(const String &p_newtext); void _pick_track_filter_text_changed(const String &p_newtext);
void _pick_track_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates); void _pick_track_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates);
void _pick_track_filter_input(const Ref<InputEvent> &p_ie);
double snap_unit; double snap_unit;
void _update_snap_unit(); void _update_snap_unit();

View File

@ -425,26 +425,19 @@ void CreateDialog::_text_changed(const String &p_newtext) {
_update_search(); _update_search();
} }
void CreateDialog::_sbox_input(const Ref<InputEvent> &p_ie) { void CreateDialog::_sbox_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_ie; // Redirect navigational key events to the tree.
if (k.is_valid() && k->is_pressed()) { Ref<InputEventKey> key = p_event;
switch (k->get_keycode()) { if (key.is_valid()) {
case Key::UP: if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
case Key::DOWN: search_options->gui_input(key);
case Key::PAGEUP: search_box->accept_event();
case Key::PAGEDOWN: { } else if (key->is_action_pressed("ui_select", true)) {
search_options->gui_input(k); TreeItem *ti = search_options->get_selected();
search_box->accept_event(); if (ti) {
} break; ti->set_collapsed(!ti->is_collapsed());
case Key::SPACE: { }
TreeItem *ti = search_options->get_selected(); search_box->accept_event();
if (ti) {
ti->set_collapsed(!ti->is_collapsed());
}
search_box->accept_event();
} break;
default:
break;
} }
} }
} }

View File

@ -77,7 +77,7 @@ class CreateDialog : public ConfirmationDialog {
void _fill_type_list(); void _fill_type_list();
void _cleanup(); void _cleanup();
void _sbox_input(const Ref<InputEvent> &p_ie); void _sbox_input(const Ref<InputEvent> &p_event);
void _text_changed(const String &p_newtext); void _text_changed(const String &p_newtext);
void select_type(const String &p_type, bool p_center_on_item = true); void select_type(const String &p_type, bool p_center_on_item = true);
void _item_selected(); void _item_selected();

View File

@ -183,18 +183,13 @@ void EditorCommandPalette::_notification(int p_what) {
} }
} }
void EditorCommandPalette::_sbox_input(const Ref<InputEvent> &p_ie) { void EditorCommandPalette::_sbox_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_ie; // Redirect navigational key events to the tree.
if (k.is_valid()) { Ref<InputEventKey> key = p_event;
switch (k->get_keycode()) { if (key.is_valid()) {
case Key::UP: if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
case Key::DOWN: search_options->gui_input(key);
case Key::PAGEUP: command_search_box->accept_event();
case Key::PAGEDOWN: {
search_options->gui_input(k);
} break;
default:
break;
} }
} }
} }

View File

@ -80,7 +80,7 @@ class EditorCommandPalette : public ConfirmationDialog {
void _update_command_search(const String &search_text); void _update_command_search(const String &search_text);
float _score_path(const String &p_search, const String &p_path); float _score_path(const String &p_search, const String &p_path);
void _sbox_input(const Ref<InputEvent> &p_ie); void _sbox_input(const Ref<InputEvent> &p_event);
void _confirmed(); void _confirmed();
void _add_command(String p_command_name, String p_key_name, Callable p_binded_action, String p_shortcut_text = "None"); void _add_command(String p_command_name, String p_key_name, Callable p_binded_action, String p_shortcut_text = "None");
void _save_history() const; void _save_history() const;

View File

@ -169,19 +169,12 @@ void EditorHelpSearch::_update_results() {
} }
void EditorHelpSearch::_search_box_gui_input(const Ref<InputEvent> &p_event) { void EditorHelpSearch::_search_box_gui_input(const Ref<InputEvent> &p_event) {
// Redirect up and down navigational key events to the results list. // Redirect navigational key events to the tree.
Ref<InputEventKey> key = p_event; Ref<InputEventKey> key = p_event;
if (key.is_valid()) { if (key.is_valid()) {
switch (key->get_keycode()) { if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
case Key::UP: results_tree->gui_input(key);
case Key::DOWN: search_box->accept_event();
case Key::PAGEUP:
case Key::PAGEDOWN: {
results_tree->gui_input(key);
search_box->accept_event();
} break;
default:
break;
} }
} }
} }

View File

@ -202,36 +202,30 @@ void EditorQuickOpen::_text_changed(const String &p_newtext) {
_update_search(); _update_search();
} }
void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) { void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_ie; // Redirect navigational key events to the tree.
if (k.is_valid()) { Ref<InputEventKey> key = p_event;
switch (k->get_keycode()) { if (key.is_valid()) {
case Key::UP: if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
case Key::DOWN: search_options->gui_input(key);
case Key::PAGEUP: search_box->accept_event();
case Key::PAGEDOWN: {
search_options->gui_input(k);
search_box->accept_event();
if (allow_multi_select) { if (allow_multi_select) {
TreeItem *root = search_options->get_root(); TreeItem *root = search_options->get_root();
if (!root->get_first_child()) { if (!root->get_first_child()) {
break; return;
}
TreeItem *current = search_options->get_selected();
TreeItem *item = search_options->get_next_selected(root);
while (item) {
item->deselect(0);
item = search_options->get_next_selected(item);
}
current->select(0);
current->set_as_cursor(0);
} }
} break;
default: TreeItem *current = search_options->get_selected();
break; TreeItem *item = search_options->get_next_selected(root);
while (item) {
item->deselect(0);
item = search_options->get_next_selected(item);
}
current->select(0);
current->set_as_cursor(0);
}
} }
} }
} }

View File

@ -69,7 +69,7 @@ class EditorQuickOpen : public ConfirmationDialog {
virtual void cancel_pressed() override; virtual void cancel_pressed() override;
void _cleanup(); void _cleanup();
void _sbox_input(const Ref<InputEvent> &p_ie); void _sbox_input(const Ref<InputEvent> &p_event);
void _text_changed(const String &p_newtext); void _text_changed(const String &p_newtext);
protected: protected:

View File

@ -1744,6 +1744,17 @@ void SceneTreeDialog::_filter_changed(const String &p_filter) {
tree->set_filter(p_filter); tree->set_filter(p_filter);
} }
void SceneTreeDialog::_on_filter_gui_input(const Ref<InputEvent> &p_event) {
// Redirect navigational key events to the tree.
Ref<InputEventKey> key = p_event;
if (key.is_valid()) {
if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
tree->get_scene_tree()->gui_input(key);
filter->accept_event();
}
}
}
void SceneTreeDialog::_bind_methods() { void SceneTreeDialog::_bind_methods() {
ClassDB::bind_method("_cancel", &SceneTreeDialog::_cancel); ClassDB::bind_method("_cancel", &SceneTreeDialog::_cancel);
@ -1764,6 +1775,10 @@ SceneTreeDialog::SceneTreeDialog() {
filter->set_clear_button_enabled(true); filter->set_clear_button_enabled(true);
filter->add_theme_constant_override("minimum_character_width", 0); filter->add_theme_constant_override("minimum_character_width", 0);
filter->connect(SceneStringName(text_changed), callable_mp(this, &SceneTreeDialog::_filter_changed)); filter->connect(SceneStringName(text_changed), callable_mp(this, &SceneTreeDialog::_filter_changed));
filter->connect(SceneStringName(gui_input), callable_mp(this, &SceneTreeDialog::_on_filter_gui_input));
register_text_enter(filter);
filter_hbc->add_child(filter); filter_hbc->add_child(filter);
// Add 'Show All' button to HBoxContainer next to the filter, visible only when valid_types is defined. // Add 'Show All' button to HBoxContainer next to the filter, visible only when valid_types is defined.

View File

@ -195,6 +195,7 @@ class SceneTreeDialog : public ConfirmationDialog {
void _cancel(); void _cancel();
void _selected_changed(); void _selected_changed();
void _filter_changed(const String &p_filter); void _filter_changed(const String &p_filter);
void _on_filter_gui_input(const Ref<InputEvent> &p_event);
void _show_all_nodes_changed(bool p_button_pressed); void _show_all_nodes_changed(bool p_button_pressed);
protected: protected:

View File

@ -358,12 +358,14 @@ void ScriptEditorQuickOpen::_text_changed(const String &p_newtext) {
_update_search(); _update_search();
} }
void ScriptEditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) { void ScriptEditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_ie; // Redirect navigational key events to the tree.
Ref<InputEventKey> key = p_event;
if (k.is_valid() && (k->get_keycode() == Key::UP || k->get_keycode() == Key::DOWN || k->get_keycode() == Key::PAGEUP || k->get_keycode() == Key::PAGEDOWN)) { if (key.is_valid()) {
search_options->gui_input(k); if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
search_box->accept_event(); search_options->gui_input(key);
search_box->accept_event();
}
} }
} }

View File

@ -131,7 +131,7 @@ class ScriptEditorQuickOpen : public ConfirmationDialog {
void _update_search(); void _update_search();
void _sbox_input(const Ref<InputEvent> &p_ie); void _sbox_input(const Ref<InputEvent> &p_event);
Vector<String> functions; Vector<String> functions;
void _confirmed(); void _confirmed();

View File

@ -2174,19 +2174,13 @@ void ThemeTypeDialog::_add_type_filter_cbk(const String &p_value) {
_update_add_type_options(p_value); _update_add_type_options(p_value);
} }
void ThemeTypeDialog::_type_filter_input(const Ref<InputEvent> &p_ie) { void ThemeTypeDialog::_type_filter_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_ie; // Redirect navigational key events to the item list.
if (k.is_valid() && k->is_pressed()) { Ref<InputEventKey> key = p_event;
switch (k->get_keycode()) { if (key.is_valid()) {
case Key::UP: if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
case Key::DOWN: add_type_options->gui_input(key);
case Key::PAGEUP: add_type_filter->accept_event();
case Key::PAGEDOWN: {
add_type_options->gui_input(k);
add_type_filter->accept_event();
} break;
default:
break;
} }
} }
} }

View File

@ -303,7 +303,7 @@ class ThemeTypeDialog : public ConfirmationDialog {
void _update_add_type_options(const String &p_filter = ""); void _update_add_type_options(const String &p_filter = "");
void _add_type_filter_cbk(const String &p_value); void _add_type_filter_cbk(const String &p_value);
void _type_filter_input(const Ref<InputEvent> &p_ie); void _type_filter_input(const Ref<InputEvent> &p_event);
void _add_type_options_cbk(int p_index); void _add_type_options_cbk(int p_index);
void _add_type_dialog_entered(const String &p_value); void _add_type_dialog_entered(const String &p_value);
void _add_type_dialog_activated(int p_index); void _add_type_dialog_activated(int p_index);

View File

@ -2148,6 +2148,7 @@ String VisualShaderEditor::_get_description(int p_idx) {
void VisualShaderEditor::_update_options_menu() { void VisualShaderEditor::_update_options_menu() {
node_desc->set_text(""); node_desc->set_text("");
highend_label->set_visible(false);
members_dialog->get_ok_button()->set_disabled(true); members_dialog->get_ok_button()->set_disabled(true);
members->clear(); members->clear();
@ -2312,6 +2313,8 @@ void VisualShaderEditor::_update_options_menu() {
item->select(0); item->select(0);
node_desc->set_text(options[i].description); node_desc->set_text(options[i].description);
is_first_item = false; is_first_item = false;
members_dialog->get_ok_button()->set_disabled(false);
} }
switch (options[i].return_type) { switch (options[i].return_type) {
case VisualShaderNode::PORT_TYPE_SCALAR: case VisualShaderNode::PORT_TYPE_SCALAR:
@ -4924,7 +4927,7 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos, VisualShaderNod
Vector2 difference = (dialog_rect.get_end() - window_rect.get_end()).maxf(0); Vector2 difference = (dialog_rect.get_end() - window_rect.get_end()).maxf(0);
members_dialog->set_position(members_dialog->get_position() - difference); members_dialog->set_position(members_dialog->get_position() - difference);
callable_mp((Control *)node_filter, &Control::grab_focus).call_deferred(); // Still not visible. node_filter->grab_focus();
node_filter->select_all(); node_filter->select_all();
} }
@ -4947,6 +4950,8 @@ void VisualShaderEditor::_show_add_varying_dialog() {
add_varying_dialog->set_position(graph->get_screen_position() + varying_button->get_position() + Point2(5 * EDSCALE, 65 * EDSCALE)); add_varying_dialog->set_position(graph->get_screen_position() + varying_button->get_position() + Point2(5 * EDSCALE, 65 * EDSCALE));
add_varying_dialog->popup(); add_varying_dialog->popup();
varying_name->grab_focus();
// Keep dialog within window bounds. // Keep dialog within window bounds.
Rect2 window_rect = Rect2(DisplayServer::get_singleton()->window_get_position(), DisplayServer::get_singleton()->window_get_size()); Rect2 window_rect = Rect2(DisplayServer::get_singleton()->window_get_position(), DisplayServer::get_singleton()->window_get_size());
Rect2 dialog_rect = Rect2(add_varying_dialog->get_position(), add_varying_dialog->get_size()); Rect2 dialog_rect = Rect2(add_varying_dialog->get_position(), add_varying_dialog->get_size());
@ -4958,6 +4963,8 @@ void VisualShaderEditor::_show_remove_varying_dialog() {
remove_varying_dialog->set_position(graph->get_screen_position() + varying_button->get_position() + Point2(5 * EDSCALE, 65 * EDSCALE)); remove_varying_dialog->set_position(graph->get_screen_position() + varying_button->get_position() + Point2(5 * EDSCALE, 65 * EDSCALE));
remove_varying_dialog->popup(); remove_varying_dialog->popup();
varyings->grab_focus();
// Keep dialog within window bounds. // Keep dialog within window bounds.
Rect2 window_rect = Rect2(DisplayServer::get_singleton()->window_get_position(), DisplayServer::get_singleton()->window_get_size()); Rect2 window_rect = Rect2(DisplayServer::get_singleton()->window_get_position(), DisplayServer::get_singleton()->window_get_size());
Rect2 dialog_rect = Rect2(remove_varying_dialog->get_position(), remove_varying_dialog->get_size()); Rect2 dialog_rect = Rect2(remove_varying_dialog->get_position(), remove_varying_dialog->get_size());
@ -4965,11 +4972,14 @@ void VisualShaderEditor::_show_remove_varying_dialog() {
remove_varying_dialog->set_position(remove_varying_dialog->get_position() - difference); remove_varying_dialog->set_position(remove_varying_dialog->get_position() - difference);
} }
void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) { void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> ie = p_ie; // Redirect navigational key events to the tree.
if (ie.is_valid() && (ie->get_keycode() == Key::UP || ie->get_keycode() == Key::DOWN || ie->get_keycode() == Key::ENTER || ie->get_keycode() == Key::KP_ENTER)) { Ref<InputEventKey> key = p_event;
members->gui_input(ie); if (key.is_valid()) {
node_filter->accept_event(); if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
members->gui_input(key);
node_filter->accept_event();
}
} }
} }
@ -5700,9 +5710,6 @@ void VisualShaderEditor::_member_selected() {
} }
} }
void VisualShaderEditor::_member_unselected() {
}
void VisualShaderEditor::_member_create() { void VisualShaderEditor::_member_create() {
TreeItem *item = members->get_selected(); TreeItem *item = members->get_selected();
if (item != nullptr && item->has_meta("id")) { if (item != nullptr && item->has_meta("id")) {
@ -6092,7 +6099,6 @@ void VisualShaderEditor::_show_preview_text() {
} else { } else {
code_preview_window->popup(); code_preview_window->popup();
} }
_preview_size_changed();
if (pending_update_preview) { if (pending_update_preview) {
_update_preview(); _update_preview();
@ -6105,14 +6111,9 @@ void VisualShaderEditor::_show_preview_text() {
void VisualShaderEditor::_preview_close_requested() { void VisualShaderEditor::_preview_close_requested() {
code_preview_showed = false; code_preview_showed = false;
code_preview_window->hide();
code_preview_button->set_pressed(false); code_preview_button->set_pressed(false);
} }
void VisualShaderEditor::_preview_size_changed() {
code_preview_vbox->set_custom_minimum_size(code_preview_window->get_size());
}
static ShaderLanguage::DataType _visual_shader_editor_get_global_shader_uniform_type(const StringName &p_variable) { static ShaderLanguage::DataType _visual_shader_editor_get_global_shader_uniform_type(const StringName &p_variable) {
RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable); RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable);
return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt); return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt);
@ -6460,12 +6461,12 @@ VisualShaderEditor::VisualShaderEditor() {
// CODE PREVIEW // CODE PREVIEW
/////////////////////////////////////// ///////////////////////////////////////
code_preview_window = memnew(Window); code_preview_window = memnew(AcceptDialog);
code_preview_window->set_title(TTR("Generated Shader Code")); code_preview_window->set_title(TTR("Generated Shader Code"));
code_preview_window->set_visible(code_preview_showed); code_preview_window->set_visible(code_preview_showed);
code_preview_window->set_exclusive(true); code_preview_window->set_ok_button_text(TTR("Close"));
code_preview_window->connect("close_requested", callable_mp(this, &VisualShaderEditor::_preview_close_requested)); code_preview_window->connect(SceneStringName(confirmed), callable_mp(this, &VisualShaderEditor::_preview_close_requested));
code_preview_window->connect("size_changed", callable_mp(this, &VisualShaderEditor::_preview_size_changed)); code_preview_window->connect("canceled", callable_mp(this, &VisualShaderEditor::_preview_close_requested));
add_child(code_preview_window); add_child(code_preview_window);
code_preview_vbox = memnew(VBoxContainer); code_preview_vbox = memnew(VBoxContainer);
@ -6612,7 +6613,6 @@ VisualShaderEditor::VisualShaderEditor() {
members->set_custom_minimum_size(Size2(180 * EDSCALE, 200 * EDSCALE)); members->set_custom_minimum_size(Size2(180 * EDSCALE, 200 * EDSCALE));
members->connect("item_activated", callable_mp(this, &VisualShaderEditor::_member_create)); members->connect("item_activated", callable_mp(this, &VisualShaderEditor::_member_create));
members->connect(SceneStringName(item_selected), callable_mp(this, &VisualShaderEditor::_member_selected)); members->connect(SceneStringName(item_selected), callable_mp(this, &VisualShaderEditor::_member_selected));
members->connect("nothing_selected", callable_mp(this, &VisualShaderEditor::_member_unselected));
HBoxContainer *desc_hbox = memnew(HBoxContainer); HBoxContainer *desc_hbox = memnew(HBoxContainer);
members_vb->add_child(desc_hbox); members_vb->add_child(desc_hbox);
@ -6638,21 +6638,20 @@ VisualShaderEditor::VisualShaderEditor() {
members_dialog = memnew(ConfirmationDialog); members_dialog = memnew(ConfirmationDialog);
members_dialog->set_title(TTR("Create Shader Node")); members_dialog->set_title(TTR("Create Shader Node"));
members_dialog->set_exclusive(true);
members_dialog->add_child(members_vb); members_dialog->add_child(members_vb);
members_dialog->set_ok_button_text(TTR("Create")); members_dialog->set_ok_button_text(TTR("Create"));
members_dialog->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &VisualShaderEditor::_member_create)); members_dialog->connect(SceneStringName(confirmed), callable_mp(this, &VisualShaderEditor::_member_create));
members_dialog->get_ok_button()->set_disabled(true); members_dialog->get_ok_button()->set_disabled(true);
members_dialog->connect("canceled", callable_mp(this, &VisualShaderEditor::_member_cancel)); members_dialog->connect("canceled", callable_mp(this, &VisualShaderEditor::_member_cancel));
members_dialog->register_text_enter(node_filter);
add_child(members_dialog); add_child(members_dialog);
// add varyings dialog // add varyings dialog
{ {
add_varying_dialog = memnew(ConfirmationDialog); add_varying_dialog = memnew(ConfirmationDialog);
add_varying_dialog->set_title(TTR("Create Shader Varying")); add_varying_dialog->set_title(TTR("Create Shader Varying"));
add_varying_dialog->set_exclusive(true);
add_varying_dialog->set_ok_button_text(TTR("Create")); add_varying_dialog->set_ok_button_text(TTR("Create"));
add_varying_dialog->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &VisualShaderEditor::_varying_create)); add_varying_dialog->connect(SceneStringName(confirmed), callable_mp(this, &VisualShaderEditor::_varying_create));
add_varying_dialog->get_ok_button()->set_disabled(true); add_varying_dialog->get_ok_button()->set_disabled(true);
add_child(add_varying_dialog); add_child(add_varying_dialog);
@ -6679,6 +6678,7 @@ VisualShaderEditor::VisualShaderEditor() {
varying_name->set_custom_minimum_size(Size2(150 * EDSCALE, 0)); varying_name->set_custom_minimum_size(Size2(150 * EDSCALE, 0));
varying_name->set_h_size_flags(SIZE_EXPAND_FILL); varying_name->set_h_size_flags(SIZE_EXPAND_FILL);
varying_name->connect(SceneStringName(text_changed), callable_mp(this, &VisualShaderEditor::_varying_name_changed)); varying_name->connect(SceneStringName(text_changed), callable_mp(this, &VisualShaderEditor::_varying_name_changed));
add_varying_dialog->register_text_enter(varying_name);
varying_mode = memnew(OptionButton); varying_mode = memnew(OptionButton);
hb->add_child(varying_mode); hb->add_child(varying_mode);
@ -6696,9 +6696,8 @@ VisualShaderEditor::VisualShaderEditor() {
{ {
remove_varying_dialog = memnew(ConfirmationDialog); remove_varying_dialog = memnew(ConfirmationDialog);
remove_varying_dialog->set_title(TTR("Delete Shader Varying")); remove_varying_dialog->set_title(TTR("Delete Shader Varying"));
remove_varying_dialog->set_exclusive(true);
remove_varying_dialog->set_ok_button_text(TTR("Delete")); remove_varying_dialog->set_ok_button_text(TTR("Delete"));
remove_varying_dialog->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &VisualShaderEditor::_varying_deleted)); remove_varying_dialog->connect(SceneStringName(confirmed), callable_mp(this, &VisualShaderEditor::_varying_deleted));
add_child(remove_varying_dialog); add_child(remove_varying_dialog);
VBoxContainer *vb = memnew(VBoxContainer); VBoxContainer *vb = memnew(VBoxContainer);

View File

@ -230,7 +230,7 @@ class VisualShaderEditor : public ShaderEditor {
bool pending_update_preview = false; bool pending_update_preview = false;
bool shader_error = false; bool shader_error = false;
Window *code_preview_window = nullptr; AcceptDialog *code_preview_window = nullptr;
VBoxContainer *code_preview_vbox = nullptr; VBoxContainer *code_preview_vbox = nullptr;
CodeEdit *preview_text = nullptr; CodeEdit *preview_text = nullptr;
Ref<CodeHighlighter> syntax_highlighter = nullptr; Ref<CodeHighlighter> syntax_highlighter = nullptr;
@ -576,9 +576,8 @@ class VisualShaderEditor : public ShaderEditor {
void _graph_gui_input(const Ref<InputEvent> &p_event); void _graph_gui_input(const Ref<InputEvent> &p_event);
void _member_filter_changed(const String &p_text); void _member_filter_changed(const String &p_text);
void _sbox_input(const Ref<InputEvent> &p_ie); void _sbox_input(const Ref<InputEvent> &p_event);
void _member_selected(); void _member_selected();
void _member_unselected();
void _member_create(); void _member_create();
void _member_cancel(); void _member_cancel();

View File

@ -30,49 +30,38 @@
#include "property_selector.h" #include "property_selector.h"
#include "core/os/keyboard.h"
#include "editor/doc_tools.h"
#include "editor/editor_help.h" #include "editor/editor_help.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/themes/editor_scale.h" #include "editor/themes/editor_scale.h"
#include "scene/gui/line_edit.h" #include "scene/gui/line_edit.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/tree.h" #include "scene/gui/tree.h"
void PropertySelector::_text_changed(const String &p_newtext) { void PropertySelector::_text_changed(const String &p_newtext) {
_update_search(); _update_search();
} }
void PropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) { void PropertySelector::_sbox_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_ie; // Redirect navigational key events to the tree.
Ref<InputEventKey> key = p_event;
if (key.is_valid()) {
if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
search_options->gui_input(key);
search_box->accept_event();
if (k.is_valid()) { TreeItem *root = search_options->get_root();
switch (k->get_keycode()) { if (!root->get_first_child()) {
case Key::UP: return;
case Key::DOWN: }
case Key::PAGEUP:
case Key::PAGEDOWN: {
search_options->gui_input(k);
search_box->accept_event();
TreeItem *root = search_options->get_root(); TreeItem *current = search_options->get_selected();
if (!root->get_first_child()) {
break;
}
TreeItem *current = search_options->get_selected(); TreeItem *item = search_options->get_next_selected(root);
while (item) {
item->deselect(0);
item = search_options->get_next_selected(item);
}
TreeItem *item = search_options->get_next_selected(root); current->select(0);
while (item) {
item->deselect(0);
item = search_options->get_next_selected(item);
}
current->select(0);
} break;
default:
break;
} }
} }
} }
@ -313,7 +302,7 @@ void PropertySelector::_update_search() {
} }
} }
get_ok_button()->set_disabled(root->get_first_child() == nullptr); get_ok_button()->set_disabled(search_options->get_selected() == nullptr);
} }
void PropertySelector::_confirmed() { void PropertySelector::_confirmed() {
@ -329,6 +318,8 @@ void PropertySelector::_item_selected() {
help_bit->set_custom_text(String(), String(), String()); help_bit->set_custom_text(String(), String(), String());
TreeItem *item = search_options->get_selected(); TreeItem *item = search_options->get_selected();
get_ok_button()->set_disabled(item == nullptr);
if (!item) { if (!item) {
return; return;
} }

View File

@ -45,7 +45,7 @@ class PropertySelector : public ConfirmationDialog {
Tree *search_options = nullptr; Tree *search_options = nullptr;
void _text_changed(const String &p_newtext); void _text_changed(const String &p_newtext);
void _sbox_input(const Ref<InputEvent> &p_ie); void _sbox_input(const Ref<InputEvent> &p_event);
void _update_search(); void _update_search();
void _confirmed(); void _confirmed();
void _item_selected(); void _item_selected();

View File

@ -815,13 +815,14 @@ void GridMapEditor::_text_changed(const String &p_text) {
update_palette(); update_palette();
} }
void GridMapEditor::_sbox_input(const Ref<InputEvent> &p_ie) { void GridMapEditor::_sbox_input(const Ref<InputEvent> &p_event) {
const Ref<InputEventKey> k = p_ie; // Redirect navigational key events to the item list.
Ref<InputEventKey> key = p_event;
if (k.is_valid() && (k->get_keycode() == Key::UP || k->get_keycode() == Key::DOWN || k->get_keycode() == Key::PAGEUP || k->get_keycode() == Key::PAGEDOWN)) { if (key.is_valid()) {
// Forward the key input to the ItemList so it can be scrolled if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) {
mesh_library_palette->gui_input(k); mesh_library_palette->gui_input(key);
search_box->accept_event(); search_box->accept_event();
}
} }
} }

View File

@ -199,7 +199,7 @@ class GridMapEditor : public VBoxContainer {
void _update_theme(); void _update_theme();
void _text_changed(const String &p_text); void _text_changed(const String &p_text);
void _sbox_input(const Ref<InputEvent> &p_ie); void _sbox_input(const Ref<InputEvent> &p_event);
void _mesh_library_palette_input(const Ref<InputEvent> &p_ie); void _mesh_library_palette_input(const Ref<InputEvent> &p_ie);
void _icon_size_changed(float p_value); void _icon_size_changed(float p_value);

View File

@ -93,24 +93,6 @@ void ReplicationEditor::_pick_node_select_recursive(TreeItem *p_item, const Stri
} }
} }
void ReplicationEditor::_pick_node_filter_input(const Ref<InputEvent> &p_ie) {
Ref<InputEventKey> k = p_ie;
if (k.is_valid()) {
switch (k->get_keycode()) {
case Key::UP:
case Key::DOWN:
case Key::PAGEUP:
case Key::PAGEDOWN: {
pick_node->get_scene_tree()->get_scene_tree()->gui_input(k);
pick_node->get_filter_line_edit()->accept_event();
} break;
default:
break;
}
}
}
void ReplicationEditor::_pick_node_selected(NodePath p_path) { void ReplicationEditor::_pick_node_selected(NodePath p_path) {
Node *root = current->get_node(current->get_root_path()); Node *root = current->get_node(current->get_root_path());
ERR_FAIL_NULL(root); ERR_FAIL_NULL(root);
@ -184,11 +166,9 @@ ReplicationEditor::ReplicationEditor() {
pick_node = memnew(SceneTreeDialog); pick_node = memnew(SceneTreeDialog);
add_child(pick_node); add_child(pick_node);
pick_node->register_text_enter(pick_node->get_filter_line_edit());
pick_node->set_title(TTR("Pick a node to synchronize:")); pick_node->set_title(TTR("Pick a node to synchronize:"));
pick_node->connect("selected", callable_mp(this, &ReplicationEditor::_pick_node_selected)); pick_node->connect("selected", callable_mp(this, &ReplicationEditor::_pick_node_selected));
pick_node->get_filter_line_edit()->connect(SceneStringName(text_changed), callable_mp(this, &ReplicationEditor::_pick_node_filter_text_changed)); pick_node->get_filter_line_edit()->connect(SceneStringName(text_changed), callable_mp(this, &ReplicationEditor::_pick_node_filter_text_changed));
pick_node->get_filter_line_edit()->connect("gui_input", callable_mp(this, &ReplicationEditor::_pick_node_filter_input));
prop_selector = memnew(PropertySelector); prop_selector = memnew(PropertySelector);
add_child(prop_selector); add_child(prop_selector);

View File

@ -81,7 +81,6 @@ private:
void _pick_node_filter_text_changed(const String &p_newtext); void _pick_node_filter_text_changed(const String &p_newtext);
void _pick_node_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates); void _pick_node_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates);
void _pick_node_filter_input(const Ref<InputEvent> &p_ie);
void _pick_node_selected(NodePath p_path); void _pick_node_selected(NodePath p_path);
void _pick_new_property(); void _pick_new_property();