Add clear text button to LineEdit
- Add pressed state to clear button - Enable clear button on all inputs with search icon - Remove duplicate clear buttons - Fix rendering of icon for center and right alignments - Add clear button to more search fields - Add clear icon to default theme - Add method to control enabled state of clear button - Add property to enable clear button from inspector
This commit is contained in:
parent
0fc1c4eda8
commit
e8a435c8cd
23 changed files with 250 additions and 194 deletions
|
|
@ -425,6 +425,8 @@ void CreateDialog::_notification(int p_what) {
|
|||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
connect("confirmed", this, "_confirmed");
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
favorite->set_icon(get_icon("Favorites", "EditorIcons"));
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
|
|
|
|||
|
|
@ -254,6 +254,7 @@ void EditorHelpSearch::_notification(int p_what) {
|
|||
|
||||
//_update_icons
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
|
||||
connect("confirmed", this, "_confirmed");
|
||||
_update_search();
|
||||
|
|
@ -268,6 +269,7 @@ void EditorHelpSearch::_notification(int p_what) {
|
|||
|
||||
//_update_icons
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
} else if (p_what == NOTIFICATION_PROCESS) {
|
||||
|
||||
if (search.is_valid()) {
|
||||
|
|
@ -382,6 +384,7 @@ void EditorHelpIndex::_notification(int p_what) {
|
|||
|
||||
//_update_icons
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
_update_class_list();
|
||||
|
||||
connect("confirmed", this, "_tree_item_selected");
|
||||
|
|
@ -393,6 +396,7 @@ void EditorHelpIndex::_notification(int p_what) {
|
|||
|
||||
//_update_icons
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -828,6 +828,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
|
|||
theme->set_color("font_color", "LineEdit", font_color);
|
||||
theme->set_color("cursor_color", "LineEdit", font_color);
|
||||
theme->set_color("selection_color", "LineEdit", font_color_selection);
|
||||
theme->set_color("clear_button_color", "LineEdit", font_color);
|
||||
theme->set_color("clear_button_color_pressed", "LineEdit", accent_color);
|
||||
|
||||
// TextEdit
|
||||
theme->set_stylebox("normal", "TextEdit", style_widget);
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ void FileSystemDock::_notification(int p_what) {
|
|||
button_hist_next->connect("pressed", this, "_fw_history");
|
||||
button_hist_prev->connect("pressed", this, "_bw_history");
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", ei));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
|
||||
button_hist_next->set_icon(get_icon("Forward", ei));
|
||||
button_hist_prev->set_icon(get_icon("Back", ei));
|
||||
|
|
@ -253,6 +254,7 @@ void FileSystemDock::_notification(int p_what) {
|
|||
button_hist_prev->set_icon(get_icon("Back", ei));
|
||||
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", ei));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
|
||||
if (new_mode != display_mode) {
|
||||
set_display_mode(new_mode);
|
||||
|
|
|
|||
|
|
@ -288,7 +288,9 @@ void GroupDialog::_notification(int p_what) {
|
|||
remove_button->set_icon(get_icon("Back", "EditorIcons"));
|
||||
|
||||
add_filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
add_filter->set_clear_button_enabled(true);
|
||||
remove_filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
remove_filter->set_clear_button_enabled(true);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -530,6 +530,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
|
|||
search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
search->set_placeholder(TTR("Filter properties"));
|
||||
search->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search->set_clear_button_enabled(true);
|
||||
add_child(search);
|
||||
|
||||
warning = memnew(Button);
|
||||
|
|
|
|||
|
|
@ -554,6 +554,8 @@ void EditorAssetLibrary::_notification(int p_what) {
|
|||
|
||||
error_tr->set_texture(get_icon("Error", "EditorIcons"));
|
||||
reverse->set_icon(get_icon("Sort", "EditorIcons"));
|
||||
filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
filter->set_clear_button_enabled(true);
|
||||
|
||||
error_label->raise();
|
||||
} break;
|
||||
|
|
@ -604,6 +606,8 @@ void EditorAssetLibrary::_notification(int p_what) {
|
|||
library_scroll_bg->add_style_override("panel", get_stylebox("bg", "Tree"));
|
||||
error_tr->set_texture(get_icon("Error", "EditorIcons"));
|
||||
reverse->set_icon(get_icon("Sort", "EditorIcons"));
|
||||
filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
filter->set_clear_button_enabled(true);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,6 +219,9 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
|
|||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
||||
connect("confirmed", this, "_confirmed");
|
||||
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ void TileMapEditor::_notification(int p_what) {
|
|||
rotate_270->set_icon(get_icon("Rotate270", "EditorIcons"));
|
||||
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
|
||||
PopupMenu *p = options->get_popup();
|
||||
p->set_item_icon(p->get_item_index(OPTION_PAINTING), get_icon("Edit", "EditorIcons"));
|
||||
|
|
|
|||
|
|
@ -2023,18 +2023,6 @@ void ProjectListFilter::_setup_filters() {
|
|||
filter_option->add_item(TTR("Path"));
|
||||
}
|
||||
|
||||
void ProjectListFilter::_command(int p_command) {
|
||||
switch (p_command) {
|
||||
|
||||
case CMD_CLEAR_FILTER: {
|
||||
if (search_box->get_text() != "") {
|
||||
search_box->clear();
|
||||
emit_signal("filter_changed");
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectListFilter::_search_text_changed(const String &p_newtext) {
|
||||
emit_signal("filter_changed");
|
||||
}
|
||||
|
|
@ -2057,13 +2045,14 @@ void ProjectListFilter::_filter_option_selected(int p_idx) {
|
|||
|
||||
void ProjectListFilter::_notification(int p_what) {
|
||||
|
||||
if (p_what == NOTIFICATION_ENTER_TREE)
|
||||
clear_search_button->set_icon(get_icon("Close", "EditorIcons"));
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectListFilter::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_command"), &ProjectListFilter::_command);
|
||||
ClassDB::bind_method(D_METHOD("_search_text_changed"), &ProjectListFilter::_search_text_changed);
|
||||
ClassDB::bind_method(D_METHOD("_filter_option_selected"), &ProjectListFilter::_filter_option_selected);
|
||||
|
||||
|
|
@ -2088,8 +2077,4 @@ ProjectListFilter::ProjectListFilter() {
|
|||
search_box->connect("text_changed", this, "_search_text_changed");
|
||||
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
add_child(search_box);
|
||||
|
||||
clear_search_button = memnew(ToolButton);
|
||||
clear_search_button->connect("pressed", this, "_command", make_binds(CMD_CLEAR_FILTER));
|
||||
add_child(clear_search_button);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,13 +128,8 @@ class ProjectListFilter : public HBoxContainer {
|
|||
private:
|
||||
friend class ProjectManager;
|
||||
|
||||
enum Command {
|
||||
CMD_CLEAR_FILTER,
|
||||
};
|
||||
|
||||
OptionButton *filter_option;
|
||||
LineEdit *search_box;
|
||||
ToolButton *clear_search_button;
|
||||
|
||||
enum FilterOption {
|
||||
FILTER_NAME,
|
||||
|
|
@ -142,7 +137,6 @@ private:
|
|||
};
|
||||
FilterOption _current_filter;
|
||||
|
||||
void _command(int p_command);
|
||||
void _search_text_changed(const String &p_newtext);
|
||||
void _setup_filters();
|
||||
void _filter_option_selected(int p_idx);
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ void ProjectSettingsEditor::_notification(int p_what) {
|
|||
globals_editor->edit(ProjectSettings::get_singleton());
|
||||
|
||||
search_button->set_icon(get_icon("Search", "EditorIcons"));
|
||||
clear_button->set_icon(get_icon("Close", "EditorIcons"));
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
|
||||
action_add_error->add_color_override("font_color", get_color("error_color", "Editor"));
|
||||
|
||||
|
|
@ -119,7 +120,8 @@ void ProjectSettingsEditor::_notification(int p_what) {
|
|||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
|
||||
search_button->set_icon(get_icon("Search", "EditorIcons"));
|
||||
clear_button->set_icon(get_icon("Close", "EditorIcons"));
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
action_add_error->add_color_override("font_color", get_color("error_color", "Editor"));
|
||||
popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY), get_icon("Keyboard", "EditorIcons"));
|
||||
popup_add->set_item_icon(popup_add->get_item_index(INPUT_JOY_BUTTON), get_icon("JoyButton", "EditorIcons"));
|
||||
|
|
@ -1591,15 +1593,6 @@ void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) {
|
|||
}
|
||||
}
|
||||
|
||||
void ProjectSettingsEditor::_clear_search_box() {
|
||||
|
||||
if (search_box->get_text() == "")
|
||||
return;
|
||||
|
||||
search_box->clear();
|
||||
globals_editor->get_inspector()->update_tree();
|
||||
}
|
||||
|
||||
void ProjectSettingsEditor::set_plugins_page() {
|
||||
|
||||
tab_container->set_current_tab(plugin_settings->get_index());
|
||||
|
|
@ -1662,7 +1655,6 @@ void ProjectSettingsEditor::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("_translation_filter_option_changed"), &ProjectSettingsEditor::_translation_filter_option_changed);
|
||||
ClassDB::bind_method(D_METHOD("_translation_filter_mode_changed"), &ProjectSettingsEditor::_translation_filter_mode_changed);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_clear_search_box"), &ProjectSettingsEditor::_clear_search_box);
|
||||
ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettingsEditor::_toggle_search_bar);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_copy_to_platform_about_to_show"), &ProjectSettingsEditor::_copy_to_platform_about_to_show);
|
||||
|
|
@ -1753,10 +1745,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
|
|||
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
search_bar->add_child(search_box);
|
||||
|
||||
clear_button = memnew(ToolButton);
|
||||
search_bar->add_child(clear_button);
|
||||
clear_button->connect("pressed", this, "_clear_search_box");
|
||||
|
||||
globals_editor = memnew(SectionedInspector);
|
||||
props_base->add_child(globals_editor);
|
||||
globals_editor->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ class ProjectSettingsEditor : public AcceptDialog {
|
|||
HBoxContainer *search_bar;
|
||||
Button *search_button;
|
||||
LineEdit *search_box;
|
||||
ToolButton *clear_button;
|
||||
|
||||
HBoxContainer *add_prop_bar;
|
||||
AcceptDialog *message;
|
||||
|
|
@ -158,7 +157,6 @@ class ProjectSettingsEditor : public AcceptDialog {
|
|||
void _translation_filter_mode_changed(int p_mode);
|
||||
|
||||
void _toggle_search_bar(bool p_pressed);
|
||||
void _clear_search_box();
|
||||
|
||||
void _copy_to_platform_about_to_show();
|
||||
|
||||
|
|
|
|||
|
|
@ -258,6 +258,9 @@ void EditorQuickOpen::_notification(int p_what) {
|
|||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
|
||||
connect("confirmed", this, "_confirmed");
|
||||
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -863,6 +863,7 @@ void SceneTreeDock::_notification(int p_what) {
|
|||
button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons"));
|
||||
|
||||
filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
filter->set_clear_button_enabled(true);
|
||||
|
||||
EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", this, "_selection_changed");
|
||||
|
||||
|
|
@ -911,6 +912,7 @@ void SceneTreeDock::_notification(int p_what) {
|
|||
button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons"));
|
||||
|
||||
filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
filter->set_clear_button_enabled(true);
|
||||
} break;
|
||||
case NOTIFICATION_PROCESS: {
|
||||
|
||||
|
|
|
|||
|
|
@ -114,22 +114,6 @@ void EditorSettingsDialog::popup_edit_settings() {
|
|||
_focus_current_search_box();
|
||||
}
|
||||
|
||||
void EditorSettingsDialog::_clear_search_box() {
|
||||
|
||||
if (search_box->get_text() == "")
|
||||
return;
|
||||
|
||||
search_box->clear();
|
||||
inspector->get_inspector()->update_tree();
|
||||
}
|
||||
|
||||
void EditorSettingsDialog::_clear_shortcut_search_box() {
|
||||
if (shortcut_search_box->get_text() == "")
|
||||
return;
|
||||
|
||||
shortcut_search_box->clear();
|
||||
}
|
||||
|
||||
void EditorSettingsDialog::_filter_shortcuts(const String &p_filter) {
|
||||
shortcut_filter = p_filter;
|
||||
_update_shortcuts();
|
||||
|
|
@ -199,9 +183,9 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
|
|||
void EditorSettingsDialog::_update_icons() {
|
||||
|
||||
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
shortcut_search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
||||
clear_button->set_icon(get_icon("Close", "EditorIcons"));
|
||||
shortcut_clear_button->set_icon(get_icon("Close", "EditorIcons"));
|
||||
shortcut_search_box->set_clear_button_enabled(true);
|
||||
|
||||
restart_close_button->set_icon(get_icon("Close", "EditorIcons"));
|
||||
restart_container->add_style_override("panel", get_stylebox("bg", "Tree"));
|
||||
|
|
@ -411,8 +395,6 @@ void EditorSettingsDialog::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("_settings_save"), &EditorSettingsDialog::_settings_save);
|
||||
ClassDB::bind_method(D_METHOD("_settings_changed"), &EditorSettingsDialog::_settings_changed);
|
||||
ClassDB::bind_method(D_METHOD("_settings_property_edited"), &EditorSettingsDialog::_settings_property_edited);
|
||||
ClassDB::bind_method(D_METHOD("_clear_search_box"), &EditorSettingsDialog::_clear_search_box);
|
||||
ClassDB::bind_method(D_METHOD("_clear_shortcut_search_box"), &EditorSettingsDialog::_clear_shortcut_search_box);
|
||||
ClassDB::bind_method(D_METHOD("_shortcut_button_pressed"), &EditorSettingsDialog::_shortcut_button_pressed);
|
||||
ClassDB::bind_method(D_METHOD("_filter_shortcuts"), &EditorSettingsDialog::_filter_shortcuts);
|
||||
ClassDB::bind_method(D_METHOD("_update_shortcuts"), &EditorSettingsDialog::_update_shortcuts);
|
||||
|
|
@ -451,10 +433,6 @@ EditorSettingsDialog::EditorSettingsDialog() {
|
|||
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
hbc->add_child(search_box);
|
||||
|
||||
clear_button = memnew(ToolButton);
|
||||
hbc->add_child(clear_button);
|
||||
clear_button->connect("pressed", this, "_clear_search_box");
|
||||
|
||||
inspector = memnew(SectionedInspector);
|
||||
//inspector->hide_top_label();
|
||||
inspector->get_inspector()->set_use_filter(true);
|
||||
|
|
@ -500,10 +478,6 @@ EditorSettingsDialog::EditorSettingsDialog() {
|
|||
hbc->add_child(shortcut_search_box);
|
||||
shortcut_search_box->connect("text_changed", this, "_filter_shortcuts");
|
||||
|
||||
shortcut_clear_button = memnew(ToolButton);
|
||||
hbc->add_child(shortcut_clear_button);
|
||||
shortcut_clear_button->connect("pressed", this, "_clear_shortcut_search_box");
|
||||
|
||||
shortcuts = memnew(Tree);
|
||||
tab_shortcuts->add_child(shortcuts, true);
|
||||
shortcuts->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
|
|
|
|||
|
|
@ -52,8 +52,6 @@ class EditorSettingsDialog : public AcceptDialog {
|
|||
|
||||
LineEdit *search_box;
|
||||
LineEdit *shortcut_search_box;
|
||||
ToolButton *clear_button;
|
||||
ToolButton *shortcut_clear_button;
|
||||
SectionedInspector *inspector;
|
||||
|
||||
Timer *timer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue