diff options
-rw-r--r-- | gui/PopUpWidget.cpp | 10 | ||||
-rw-r--r-- | gui/PopUpWidget.h | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index 9527db6491..71d861d35c 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -315,6 +315,16 @@ void PopUpWidget::setSelected(int item) { } } +void PopUpWidget::setSelectedTag(uint32 tag) { + uint item; + for (item = 0; item < _entries.size(); ++item) { + if (_entries[item].tag == tag) { + setSelected(item); + return; + } + } +} + void PopUpWidget::drawWidget(bool hilite) { NewGui *gui = &g_gui; int x = _x + _labelWidth; diff --git a/gui/PopUpWidget.h b/gui/PopUpWidget.h index ec6a6c363c..9a5e63ad09 100644 --- a/gui/PopUpWidget.h +++ b/gui/PopUpWidget.h @@ -62,7 +62,12 @@ public: void appendEntry(const String &entry, uint32 tag = (uint32)-1); void clearEntries(); + /** Select the entry at the given index. */ void setSelected(int item); + + /** Select the first entry matching the given tag. */ + void setSelectedTag(uint32 tag); + int getSelected() const { return _selectedItem; } uint32 getSelectedTag() const { return (_selectedItem >= 0) ? _entries[_selectedItem].tag : (uint32)-1; } const String& getSelectedString() const { return (_selectedItem >= 0) ? _entries[_selectedItem].name : String::emptyString; } |