aboutsummaryrefslogtreecommitdiff
path: root/src/SearchBar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/SearchBar.cpp')
-rw-r--r--src/SearchBar.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index aafe987..0c72805 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -37,6 +37,7 @@ namespace QuickMedia {
needs_update(true),
input_masked(input_masked),
typing(false),
+ backspace_seq_count(0),
vertical_pos(0.0f)
{
text.setFillColor(text_placeholder_color);
@@ -94,7 +95,10 @@ namespace QuickMedia {
void SearchBar::update() {
sf::Int32 elapsed_time = time_since_search_update.getElapsedTime().asMilliseconds();
- if(updated_search && elapsed_time >= text_autosearch_delay) {
+ int timeout = text_autosearch_delay;
+ if(backspace_seq_count == 1)
+ timeout = 750;
+ if(updated_search && elapsed_time >= timeout) {
updated_search = false;
auto u8 = text.getString().toUtf8();
std::string *u8_str = (std::string*)&u8;
@@ -173,9 +177,11 @@ namespace QuickMedia {
}
updated_search = true;
updated_autocomplete = true;
+ ++backspace_seq_count;
time_since_search_update.restart();
}
} else if(codepoint == 13) { // Return
+ backspace_seq_count = 0;
if(onTextSubmitCallback) {
auto u8 = text.getString().toUtf8();
std::string *u8_str = (std::string*)&u8;
@@ -199,6 +205,7 @@ namespace QuickMedia {
needs_update = true;
updated_search = false;
updated_autocomplete = false;
+ backspace_seq_count = 0;
}
void SearchBar::append_text(const std::string &text_to_add) {
@@ -224,6 +231,7 @@ namespace QuickMedia {
updated_search = true;
updated_autocomplete = true;
time_since_search_update.restart();
+ backspace_seq_count = 0;
if(str[str.getSize() - 1] == '\n')
needs_update = true;
}