summaryrefslogtreecommitdiff
path: root/src/gui/widgets/dropdown.cpp
diff options
context:
space:
mode:
authorTametomo <irarice@gmail.com>2009-06-24 18:15:48 -0600
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-02-14 21:40:49 +0100
commit6a40d67e756b5cbc849ee390720a67d0c5ead1dd (patch)
tree74ca0c9995d39da5e1135fb13facb2da5190588a /src/gui/widgets/dropdown.cpp
parentc8ac922256709e51674a67195f9bdc270f9fc261 (diff)
downloadmana-6a40d67e756b5cbc849ee390720a67d0c5ead1dd.tar.gz
mana-6a40d67e756b5cbc849ee390720a67d0c5ead1dd.tar.bz2
mana-6a40d67e756b5cbc849ee390720a67d0c5ead1dd.tar.xz
mana-6a40d67e756b5cbc849ee390720a67d0c5ead1dd.zip
Fixed DropDowns not collapsing when an item was clicked on, or enter or
space was pressed. Signed-off-by: Tametomo <irarice@gmail.com>
Diffstat (limited to 'src/gui/widgets/dropdown.cpp')
-rw-r--r--src/gui/widgets/dropdown.cpp47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 8b36f19f..b2c1ce93 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -202,36 +202,25 @@ void DropDown::drawButton(gcn::Graphics *graphics)
// -- KeyListener notifications
void DropDown::keyPressed(gcn::KeyEvent& keyEvent)
{
+ if (keyEvent.isConsumed())
+ return;
+
gcn::Key key = keyEvent.getKey();
if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
- {
- if (!mDroppedDown)
- dropDown();
- keyEvent.consume();
- }
+ dropDown();
else if (key.getValue() == Key::UP)
- {
- if (!mDroppedDown)
- setSelected(getSelected() - 1);
- keyEvent.consume();
- }
+ setSelected(getSelected() - 1);
else if (key.getValue() == Key::DOWN)
- {
- if (!mDroppedDown)
- setSelected(getSelected() + 1);
- keyEvent.consume();
- }
+ setSelected(getSelected() + 1);
else if (key.getValue() == Key::HOME)
- {
setSelected(0);
- keyEvent.consume();
- }
else if (key.getValue() == Key::END)
- {
setSelected(mListBox->getListModel()->getNumberOfElements() - 1);
- keyEvent.consume();
- }
+ else
+ return;
+
+ keyEvent.consume();
}
void DropDown::focusLost(const gcn::Event& event)
@@ -240,6 +229,22 @@ void DropDown::focusLost(const gcn::Event& event)
releaseModalMouseInputFocus();
}
+void DropDown::mousePressed(gcn::MouseEvent& mouseEvent)
+{
+ gcn::DropDown::mousePressed(mouseEvent);
+
+ if (0 <= mouseEvent.getY() && mouseEvent.getY() < getHeight() &&
+ mouseEvent.getX() >= 0 && mouseEvent.getX() < getWidth() &&
+ mouseEvent.getButton() == gcn::MouseEvent::LEFT && mDroppedDown &&
+ mouseEvent.getSource() == mListBox)
+ {
+ mPushed = false;
+ foldUp();
+ releaseModalMouseInputFocus();
+ distributeActionEvent();
+ }
+}
+
void DropDown::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
{
setSelected(getSelected() - 1);