Browse Source

Added arrow keys to move

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
c3a13dc112
2 changed files with 18 additions and 0 deletions
  1. +1
    -0
      include/widgets.hpp
  2. +17
    -0
      src/widgets/ScrollWidget.cpp

+ 1
- 0
include/widgets.hpp View File

@@ -382,6 +382,7 @@ struct ScrollWidget : OpaqueWidget {


ScrollWidget(); ScrollWidget();
void step(); void step();
Widget *onMouseMove(Vec pos, Vec mouseRel);
bool onScrollOpaque(Vec scrollRel); bool onScrollOpaque(Vec scrollRel);
}; };




+ 17
- 0
src/widgets/ScrollWidget.cpp View File

@@ -35,6 +35,23 @@ void ScrollWidget::step() {
Widget::step(); Widget::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));
}
return OpaqueWidget::onMouseMove(pos, mouseRel);
}

bool ScrollWidget::onScrollOpaque(Vec scrollRel) { bool ScrollWidget::onScrollOpaque(Vec scrollRel) {
offset = offset.minus(scrollRel); offset = offset.minus(scrollRel);
return true; return true;


Loading…
Cancel
Save