diff options
author | Ira Rice <irarice@gmail.com> | 2009-04-20 22:06:05 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-04-20 22:06:05 +0200 |
commit | 654cc39c7750bd7a8d798ab5c4732ed960135573 (patch) | |
tree | 847b7f9bbd964a50e1b15639a36a69743f0dda63 /src/gui/widgets | |
parent | 0689ecac058ce1ef063b0250c48a39ed1db11f82 (diff) | |
download | Mana-654cc39c7750bd7a8d798ab5c4732ed960135573.tar.gz Mana-654cc39c7750bd7a8d798ab5c4732ed960135573.tar.bz2 Mana-654cc39c7750bd7a8d798ab5c4732ed960135573.tar.xz Mana-654cc39c7750bd7a8d798ab5c4732ed960135573.zip |
Repaired table and listbox scrolling when using the keyboard.
Signed-off-by: Tametomo <irarice@gmail.com>
Signed-off-by: Bjørn Lindeijer <bjorn@lindeijer.nl>
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/listbox.cpp | 34 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 6 |
3 files changed, 23 insertions, 19 deletions
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 1271bf77..322ed06d 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -22,6 +22,7 @@ #include "gui/widgets/listbox.h" #include "gui/palette.h" +#include "gui/sdlinput.h" #include "configuration.h" @@ -100,27 +101,34 @@ void ListBox::keyPressed(gcn::KeyEvent& keyEvent) { gcn::Key key = keyEvent.getKey(); - if (key.getValue() == gcn::Key::ENTER || key.getValue() == gcn::Key::SPACE) + if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) { distributeActionEvent(); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::UP) + else if (key.getValue() == Key::UP) { - setSelected(mSelected - 1); + if (getSelected() > 0) + setSelected(mSelected - 1); + else if (getSelected() == 0 && mWrappingEnabled) + setSelected(getListModel()->getNumberOfElements() - 1); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::DOWN) + else if (key.getValue() == Key::DOWN) { - setSelected(mSelected + 1); + if (getSelected() < (getListModel()->getNumberOfElements() - 1)) + setSelected(mSelected + 1); + else if (getSelected() == (getListModel()->getNumberOfElements() - 1) && + mWrappingEnabled) + setSelected(0); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::HOME) + else if (key.getValue() == Key::HOME) { setSelected(0); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::END) + else if (key.getValue() == Key::END) { setSelected(getListModel()->getNumberOfElements() - 1); keyEvent.consume(); @@ -131,10 +139,10 @@ void ListBox::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) { if (isFocused()) { - if (getSelected() > 0 || (getSelected() == 0 && mWrappingEnabled)) - { + if (getSelected() > 0) setSelected(getSelected() - 1); - } + else if (getSelected() == 0 && mWrappingEnabled) + setSelected(getListModel()->getNumberOfElements() - 1); mouseEvent.consume(); } @@ -144,7 +152,11 @@ void ListBox::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) { if (isFocused()) { - setSelected(getSelected() + 1); + if (getSelected() < (getListModel()->getNumberOfElements() - 1)) + setSelected(getSelected() + 1); + else if (getSelected() == (getListModel()->getNumberOfElements() - 1) && + mWrappingEnabled) + setSelected(0); mouseEvent.consume(); } diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index 8c28c20b..799a1e7f 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -54,9 +54,7 @@ ResizeGrip::~ResizeGrip() mInstances--; if (mInstances == 0) - { gripImage->decRef(); - } } void ResizeGrip::draw(gcn::Graphics *graphics) diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index de48dfa2..dde455e6 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -377,9 +377,7 @@ void Window::mouseReleased(gcn::MouseEvent &event) void Window::mouseExited(gcn::MouseEvent &event) { if (mGrip && !mouseResize) - { gui->setCursorType(Gui::CURSOR_POINTER); - } } void Window::mouseMoved(gcn::MouseEvent &event) @@ -435,9 +433,7 @@ void Window::mouseDragged(gcn::MouseEvent &event) std::max(mMinWinHeight, newHeight)); if (mouseResize & TOP) - { newDim.y -= newDim.height - getHeight(); - } } if (mouseResize & (LEFT | RIGHT)) @@ -447,9 +443,7 @@ void Window::mouseDragged(gcn::MouseEvent &event) std::max(mMinWinWidth, newWidth)); if (mouseResize & LEFT) - { newDim.x -= newDim.width - getWidth(); - } } // Keep guichan window inside screen (supports resizing any side) |