mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:07:34 +00:00
LibGUI: Add ComboBox::selected_index()
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. :^)
This commit is contained in:
parent
50076997f4
commit
8055813ecf
2 changed files with 6 additions and 0 deletions
|
@ -163,6 +163,11 @@ void ComboBox::set_selected_index(size_t index)
|
||||||
this->m_list_view->selection().set(model_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()
|
void ComboBox::select_all()
|
||||||
{
|
{
|
||||||
m_editor->select_all();
|
m_editor->select_all();
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
const Model* model() const;
|
const Model* model() const;
|
||||||
void set_model(NonnullRefPtr<Model>);
|
void set_model(NonnullRefPtr<Model>);
|
||||||
|
|
||||||
|
size_t selected_index() const;
|
||||||
void set_selected_index(size_t index);
|
void set_selected_index(size_t index);
|
||||||
|
|
||||||
bool only_allow_values_from_model() const { return m_only_allow_values_from_model; }
|
bool only_allow_values_from_model() const { return m_only_allow_values_from_model; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue