This returns the currently selected index. It was a bit strange that we had set_selected_index() but not a way to read it back. :^)
@@ -163,6 +163,11 @@ void ComboBox::set_selected_index(size_t index)
this->m_list_view->selection().set(model_index);
}
+size_t ComboBox::selected_index() const
+{
+ return m_list_view->selection().first().row();
+}
+
void ComboBox::select_all()
{
m_editor->select_all();
@@ -49,6 +49,7 @@ public:
const Model* model() const;
void set_model(NonnullRefPtr<Model>);
+ size_t selected_index() const;
void set_selected_index(size_t index);
bool only_allow_values_from_model() const { return m_only_allow_values_from_model; }