mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 04:50:29 +00:00
LibGUI: Call on_change when set text is called
If there is an on_change callback, and we found at least one match, call the callback.
This commit is contained in:
parent
0e53b87261
commit
8b4e2e2099
Notes:
sideshowbarker
2024-07-16 23:57:20 +09:00
Author: https://github.com/lanmonster Commit: https://github.com/SerenityOS/serenity/commit/8b4e2e2099 Pull-request: https://github.com/SerenityOS/serenity/pull/23589 Reviewed-by: https://github.com/AtkinsSJ
1 changed files with 6 additions and 1 deletions
|
@ -292,7 +292,12 @@ ByteString ComboBox::text() const
|
|||
|
||||
void ComboBox::set_text(ByteString const& text, AllowCallback allow_callback)
|
||||
{
|
||||
m_editor->set_text(text, allow_callback);
|
||||
m_editor->set_text(text);
|
||||
if (!on_change || allow_callback == AllowCallback::No)
|
||||
return;
|
||||
auto matches = model()->matches(text.view(), GUI::Model::MatchesFlag::FirstMatchOnly);
|
||||
if (!matches.is_empty())
|
||||
on_change(text, matches.first());
|
||||
}
|
||||
|
||||
void ComboBox::set_only_allow_values_from_model(bool b)
|
||||
|
|
Loading…
Reference in a new issue