From 1349b8b10ff8faa9c5490d967e6b5b0ed8f43858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Tue, 28 Sep 2021 17:21:43 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibGUI/ComboBox.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index 5eee3508ab..e84846b523 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -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