From e6d56d8dd9ce943ac153f4fc1cd94044cba07dbc Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 8 Oct 2017 08:53:25 -0400 Subject: [PATCH] Scroll ScrollWidget with arrow keys on when nothing is focused --- src/widgets/ScrollWidget.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/widgets/ScrollWidget.cpp b/src/widgets/ScrollWidget.cpp index b976a0e9..f8608a5d 100644 --- a/src/widgets/ScrollWidget.cpp +++ b/src/widgets/ScrollWidget.cpp @@ -36,18 +36,20 @@ void ScrollWidget::step() { } Widget *ScrollWidget::onMouseMove(Vec pos, Vec mouseRel) { - const float arrowSpeed = 50.0; - if (glfwGetKey(gWindow, GLFW_KEY_LEFT) == GLFW_PRESS) { - offset = offset.minus(Vec(1, 0).mult(arrowSpeed)); - } - if (glfwGetKey(gWindow, GLFW_KEY_RIGHT) == GLFW_PRESS) { - offset = offset.minus(Vec(-1, 0).mult(arrowSpeed)); - } - if (glfwGetKey(gWindow, GLFW_KEY_UP) == GLFW_PRESS) { - offset = offset.minus(Vec(0, 1).mult(arrowSpeed)); - } - if (glfwGetKey(gWindow, GLFW_KEY_DOWN) == GLFW_PRESS) { - offset = offset.minus(Vec(0, -1).mult(arrowSpeed)); + if (!gFocusedWidget) { + const float arrowSpeed = 50.0; + if (glfwGetKey(gWindow, GLFW_KEY_LEFT) == GLFW_PRESS) { + offset = offset.minus(Vec(1, 0).mult(arrowSpeed)); + } + if (glfwGetKey(gWindow, GLFW_KEY_RIGHT) == GLFW_PRESS) { + offset = offset.minus(Vec(-1, 0).mult(arrowSpeed)); + } + if (glfwGetKey(gWindow, GLFW_KEY_UP) == GLFW_PRESS) { + offset = offset.minus(Vec(0, 1).mult(arrowSpeed)); + } + if (glfwGetKey(gWindow, GLFW_KEY_DOWN) == GLFW_PRESS) { + offset = offset.minus(Vec(0, -1).mult(arrowSpeed)); + } } return OpaqueWidget::onMouseMove(pos, mouseRel); }