1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:48:14 +00:00

LibGUI: Make ComboBox report on_change for set_selected_index

As navigate and navigate_relative also do this, it seems reasonable to
have it here.
This commit is contained in:
kleines Filmröllchen 2021-09-28 17:21:43 +02:00 committed by Andreas Kling
parent 642915215f
commit 1349b8b10f

View file

@ -193,8 +193,11 @@ void ComboBox::set_selected_index(size_t index)
{
if (!m_list_view->model())
return;
size_t previous_index = selected_index();
TemporaryChange change(m_updating_model, true);
m_list_view->set_cursor(m_list_view->model()->index(index, 0), AbstractView::SelectionUpdate::Set);
if (previous_index != selected_index() && on_change)
on_change(m_editor->text(), m_list_view->cursor_index());
}
size_t ComboBox::selected_index() const