Modify the PopUpWidget selection by using the mouse wheel

svn-id: r35514
This commit is contained in:
Jordi Vilalta Prat 2008-12-23 23:47:16 +00:00
parent f75893a294
commit 604b8f08b6
2 changed files with 18 additions and 0 deletions

View File

@ -379,6 +379,23 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) {
}
}
void PopUpWidget::handleMouseWheel(int x, int y, int direction) {
int newSelection = _selectedItem + direction;
// Skip separator entries
while ((newSelection >= 0) && (newSelection < (int)_entries.size()) &&
_entries[newSelection].name.equals("")) {
newSelection += direction;
}
// Just update the selected item when we're in range
if ((newSelection >= 0) && (newSelection < (int)_entries.size()) &&
(newSelection != _selectedItem)) {
_selectedItem = newSelection;
draw();
}
}
void PopUpWidget::reflowLayout() {
_leftPadding = g_gui.xmlEval()->getVar("Globals.PopUpWidget.Padding.Left", 0);
_rightPadding = g_gui.xmlEval()->getVar("Globals.PopUpWidget.Padding.Right", 0);

View File

@ -68,6 +68,7 @@ public:
void changeLabelWidth(uint newWidth) { _labelWidth = newWidth; }
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseWheel(int x, int y, int direction);
void appendEntry(const String &entry, uint32 tag = (uint32)-1);
void clearEntries();