summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-08 22:20:27 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-08 22:20:27 +0300
commitf019a9e52d0a3f5ca23681d5eb36bb2e56d37064 (patch)
tree33c4f14a56d1327b361dcc681712cfc105a7701e /src/gui/widgets
parent13b08d35c2d96ae734da14ab58d6263287e342c9 (diff)
downloadManaVerse-f019a9e52d0a3f5ca23681d5eb36bb2e56d37064.tar.gz
ManaVerse-f019a9e52d0a3f5ca23681d5eb36bb2e56d37064.tar.bz2
ManaVerse-f019a9e52d0a3f5ca23681d5eb36bb2e56d37064.tar.xz
ManaVerse-f019a9e52d0a3f5ca23681d5eb36bb2e56d37064.zip
Allow control popup menu by up/down keys.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/browserbox.cpp28
-rw-r--r--src/gui/widgets/browserbox.h6
2 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index f6f86a42d..f87bc23e3 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -914,3 +914,31 @@ void BrowserBox::setForegroundColorAll(const Color &color1,
mForegroundColor = color1;
mForegroundColor2 = color2;
}
+
+void BrowserBox::moveSelectionUp()
+{
+ if (mSelectedLink <= 0)
+ mSelectedLink = static_cast<signed>(mLinks.size()) - 1;
+ else
+ mSelectedLink --;
+}
+
+#include "logger.h"
+
+void BrowserBox::moveSelectionDown()
+{
+ mSelectedLink ++;
+ if (mSelectedLink >= static_cast<signed int>(mLinks.size()))
+ mSelectedLink = 0;
+}
+
+void BrowserBox::selectSelection()
+{
+ if (mSelectedLink < 0 || mSelectedLink >= static_cast<signed int>(
+ mLinks.size()))
+ {
+ return;
+ }
+
+ mLinkHandler->handleLink(mLinks[mSelectedLink].link, nullptr);
+}
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 85bb758f9..4fdb45189 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -196,6 +196,12 @@ class BrowserBox final : public Widget,
int getDataWidth() const
{ return mDataWidth; }
+ void moveSelectionUp();
+
+ void moveSelectionDown();
+
+ void selectSelection();
+
private:
int calcHeight() A_WARN_UNUSED;