summaryrefslogtreecommitdiff
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
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>
-rw-r--r--src/gui/widgets/dropdown.cpp47
-rw-r--r--src/gui/widgets/dropdown.h2
2 files changed, 28 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);
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index 15c52767..9bbf4f1d 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -68,6 +68,8 @@ class DropDown : public gcn::DropDown
// Inherited from MouseListener
+ void mousePressed(gcn::MouseEvent& mouseEvent);
+
void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent);
void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent);