Browse Source

Scroll ScrollWidget with arrow keys on when nothing is focused

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
e6d56d8dd9
1 changed files with 14 additions and 12 deletions
  1. +14
    -12
      src/widgets/ScrollWidget.cpp

+ 14
- 12
src/widgets/ScrollWidget.cpp View File

@@ -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);
}


Loading…
Cancel
Save