mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 06:02:07 +03:00
CharacterMap: Make the search happen as you type
This commit is contained in:
parent
1f0f96e6d7
commit
a1baa5cb00
Notes:
sideshowbarker
2024-07-18 03:23:00 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/a1baa5cb00 Pull-request: https://github.com/SerenityOS/serenity/pull/17723 Reviewed-by: https://github.com/trflynn89
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user