Skip to content

Commit

Permalink
Added mousewheel cycling through options in droplist.
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffthemedio committed Aug 2, 2015
1 parent 187ab31 commit a57d117
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions GG/GG/DropDownList.h
Expand Up @@ -179,6 +179,7 @@ class GG_API DropDownList : public Control
/** \name Mutators */ ///@{
virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys);
virtual void KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys);
virtual void MouseWheel(const Pt& pt, int move, Flags<ModKey> mod_keys);

ListBox* LB(); ///< returns the ListBox used to render the selected row and the popup list

Expand Down
20 changes: 20 additions & 0 deletions GG/src/DropDownList.cpp
Expand Up @@ -503,6 +503,26 @@ void DropDownList::KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKe
}
}

void DropDownList::MouseWheel(const Pt& pt, int move, Flags<ModKey> mod_keys)
{
if (!Disabled()) {
if (CurrentItem() == LB()->end())
return;

for (int i = 0; i < move; ++i) {
if (CurrentItem() != LB()->begin())
SelectImpl(boost::prior(CurrentItem()), true);
}

for (int i = 0; i < -move; ++i) {
if (CurrentItem() != --LB()->end())
SelectImpl(boost::next(CurrentItem()), true);
}
} else {
Control::MouseWheel(pt, move, mod_keys);
}
}

ListBox* DropDownList::LB()
{ return m_modal_picker->LB(); }

Expand Down

0 comments on commit a57d117

Please sign in to comment.