summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-03-05 15:00:54 +0000
committerAndreas Kling <kling@serenityos.org>2023-03-05 23:03:32 +0100
commita1baa5cb0084d15aeaee11021b0fc374d46025dc (patch)
tree4817a6fb8f9bdde8eb3e5d14ce0f12375deba8f2 /Userland/Applications
parent1f0f96e6d75f8e2f308bcd7766dc664d77062222 (diff)
downloadserenity-a1baa5cb0084d15aeaee11021b0fc374d46025dc.zip
CharacterMap: Make the search happen as you type
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/CharacterMap/CharacterSearchWidget.cpp5
-rw-r--r--Userland/Applications/CharacterMap/CharacterSearchWidget.h3
-rw-r--r--Userland/Applications/CharacterMap/CharacterSearchWindow.gml16
3 files changed, 5 insertions, 19 deletions
diff --git a/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp b/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp
index 29e8736563..35803cf1d5 100644
--- a/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp
+++ b/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp
@@ -8,6 +8,7 @@
#include "CharacterSearchWidget.h"
#include "SearchCharacters.h"
#include <Applications/CharacterMap/CharacterSearchWindowGML.h>
+#include <LibCore/Debounce.h>
struct SearchResult {
u32 code_point;
@@ -56,14 +57,12 @@ CharacterSearchWidget::CharacterSearchWidget()
load_from_gml(character_search_window_gml).release_value_but_fixme_should_propagate_errors();
m_search_input = find_descendant_of_type_named<GUI::TextBox>("search_input");
- m_search_button = find_descendant_of_type_named<GUI::Button>("search_button");
m_results_table = find_descendant_of_type_named<GUI::TableView>("results_table");
m_search_input->on_up_pressed = [this] { m_results_table->move_cursor(GUI::AbstractView::CursorMovement::Up, GUI::AbstractView::SelectionUpdate::Set); };
m_search_input->on_down_pressed = [this] { m_results_table->move_cursor(GUI::AbstractView::CursorMovement::Down, GUI::AbstractView::SelectionUpdate::Set); };
- m_search_input->on_return_pressed = [this] { search(); };
- m_search_button->on_click = [this](auto) { search(); };
+ m_search_input->on_change = Core::debounce([this] { search(); }, 100);
m_results_table->horizontal_scrollbar().set_visible(false);
m_results_table->set_column_headers_visible(false);
diff --git a/Userland/Applications/CharacterMap/CharacterSearchWidget.h b/Userland/Applications/CharacterMap/CharacterSearchWidget.h
index ca0fcce39a..e3745ab1a5 100644
--- a/Userland/Applications/CharacterMap/CharacterSearchWidget.h
+++ b/Userland/Applications/CharacterMap/CharacterSearchWidget.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -26,6 +26,5 @@ private:
void search();
RefPtr<GUI::TextBox> m_search_input;
- RefPtr<GUI::Button> m_search_button;
RefPtr<GUI::TableView> m_results_table;
};
diff --git a/Userland/Applications/CharacterMap/CharacterSearchWindow.gml b/Userland/Applications/CharacterMap/CharacterSearchWindow.gml
index 6ac9bf4f5a..a6815e3b5f 100644
--- a/Userland/Applications/CharacterMap/CharacterSearchWindow.gml
+++ b/Userland/Applications/CharacterMap/CharacterSearchWindow.gml
@@ -4,20 +4,8 @@
}
fill_with_background_color: true
- @GUI::Widget {
- layout: @GUI::HorizontalBoxLayout {}
- preferred_height: "fit"
-
- @GUI::TextBox {
- name: "search_input"
- }
-
- @GUI::Button {
- name: "search_button"
- icon: "/res/icons/16x16/find.png"
- button_style: "Coolbar"
- fixed_width: 22
- }
+ @GUI::TextBox {
+ name: "search_input"
}
@GUI::TableView {