summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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);