mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibGUI+FontEditor: Allow ComboBox on_change callback to be toggled
When calling set_selected_index() on ComboBox, allow its on_change callback to be disabled. Fixes FontEditor window state erroneously switching to modified when initializing between different slopes and weights.
This commit is contained in:
parent
ca062d83db
commit
298a6b9937
3 changed files with 5 additions and 5 deletions
|
@ -201,14 +201,14 @@ void ComboBox::set_model(NonnullRefPtr<Model> model)
|
|||
m_list_view->set_model(move(model));
|
||||
}
|
||||
|
||||
void ComboBox::set_selected_index(size_t index)
|
||||
void ComboBox::set_selected_index(size_t index, AllowCallback allow_callback)
|
||||
{
|
||||
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)
|
||||
if (previous_index != selected_index() && on_change && allow_callback == AllowCallback::Yes)
|
||||
on_change(m_editor->text(), m_list_view->cursor_index());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue