diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-25 16:31:25 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-25 16:31:25 +0200 |
commit | 9aecfa8da5daae017ce3ff21fd6b496fda2a690b (patch) | |
tree | 677aa76a7d4c93852201551880dd33d0207c18d6 | |
parent | e9c88090ed49fbb9e4ae7ec5141ab0714509dc39 (diff) |
Submit on suggestion should make the search bar text the selected text
-rw-r--r-- | include/SearchBar.hpp | 2 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 2 | ||||
-rw-r--r-- | src/SearchBar.cpp | 7 |
3 files changed, 9 insertions, 2 deletions
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp index 528327e..12daf58 100644 --- a/include/SearchBar.hpp +++ b/include/SearchBar.hpp @@ -27,7 +27,7 @@ namespace QuickMedia { void update(); void onWindowResize(const sf::Vector2f &window_size); void clear(); - void set_text(const std::string &text); + void set_text(const std::string &text, bool update_search = true); void append_text(const std::string &text_to_add); void set_position(sf::Vector2f pos); void set_editable(bool editable); diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 3cd32e0..091ce3b 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1891,6 +1891,8 @@ namespace QuickMedia { } if(tabs[selected_tab].page->search_is_suggestion() && !search_suggestion_submitted) { + if(tabs[selected_tab].search_bar) + tabs[selected_tab].search_bar->set_text(selected_item ? selected_item->get_title() : search_text, false); tabs[selected_tab].body->set_items(std::move(new_body_items)); tabs[selected_tab].page->submit_body_item = nullptr; tab_associated_data[selected_tab].search_suggestion_submitted = true; diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp index 0a7254b..33cea08 100644 --- a/src/SearchBar.cpp +++ b/src/SearchBar.cpp @@ -222,9 +222,14 @@ namespace QuickMedia { backspace_pressed = false; } - void SearchBar::set_text(const std::string &text) { + void SearchBar::set_text(const std::string &text, bool update_search) { clear(); append_text(text); + + if(!update_search) { + needs_update = false; + updated_search = false; + } } void SearchBar::append_text(const std::string &text_to_add) { |