@@ -38,6 +38,7 @@ void windowCursorLock(); | |||||
void windowCursorUnlock(); | void windowCursorUnlock(); | ||||
bool windowIsModPressed(); | bool windowIsModPressed(); | ||||
bool windowIsShiftPressed(); | bool windowIsShiftPressed(); | ||||
bool windowIsKeyPressed(int key); | |||||
Vec windowGetWindowSize(); | Vec windowGetWindowSize(); | ||||
void windowSetWindowSize(Vec size); | void windowSetWindowSize(Vec size); | ||||
Vec windowGetWindowPos(); | Vec windowGetWindowPos(); | ||||
@@ -1,8 +1,6 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "window.hpp" | #include "window.hpp" | ||||
#include "engine.hpp" | #include "engine.hpp" | ||||
// For GLFW_KEY_LEFT_CONTROL, etc. | |||||
#include <GLFW/glfw3.h> | |||||
namespace rack { | namespace rack { | ||||
@@ -219,7 +219,7 @@ void ModuleWidget::onMouseMove(EventMouseMove &e) { | |||||
// Don't delete the ModuleWidget if a TextField is focused | // Don't delete the ModuleWidget if a TextField is focused | ||||
if (!gFocusedWidget) { | if (!gFocusedWidget) { | ||||
// Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. | // Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. | ||||
if (glfwGetKey(gWindow, GLFW_KEY_DELETE) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_BACKSPACE) == GLFW_PRESS) { | |||||
if (windowIsKeyPressed(GLFW_KEY_DELETE) || windowIsKeyPressed(GLFW_KEY_BACKSPACE)) { | |||||
if (!windowIsModPressed() && !windowIsShiftPressed()) { | if (!windowIsModPressed() && !windowIsShiftPressed()) { | ||||
gRackWidget->deleteModule(this); | gRackWidget->deleteModule(this); | ||||
this->finalizeEvents(); | this->finalizeEvents(); | ||||
@@ -350,4 +350,4 @@ Menu *ModuleWidget::createContextMenu() { | |||||
} | } | ||||
} // namespace rack | |||||
} // namespace rack |
@@ -68,16 +68,16 @@ void ScrollWidget::onMouseMove(EventMouseMove &e) { | |||||
else if (windowIsModPressed()) | else if (windowIsModPressed()) | ||||
arrowSpeed /= 4.0; | arrowSpeed /= 4.0; | ||||
if (glfwGetKey(gWindow, GLFW_KEY_LEFT) == GLFW_PRESS) { | |||||
if (windowIsKeyPressed(GLFW_KEY_LEFT)) { | |||||
offset.x -= arrowSpeed; | offset.x -= arrowSpeed; | ||||
} | } | ||||
if (glfwGetKey(gWindow, GLFW_KEY_RIGHT) == GLFW_PRESS) { | |||||
if (windowIsKeyPressed(GLFW_KEY_RIGHT)) { | |||||
offset.x += arrowSpeed; | offset.x += arrowSpeed; | ||||
} | } | ||||
if (glfwGetKey(gWindow, GLFW_KEY_UP) == GLFW_PRESS) { | |||||
if (windowIsKeyPressed(GLFW_KEY_UP)) { | |||||
offset.y -= arrowSpeed; | offset.y -= arrowSpeed; | ||||
} | } | ||||
if (glfwGetKey(gWindow, GLFW_KEY_DOWN) == GLFW_PRESS) { | |||||
if (windowIsKeyPressed(GLFW_KEY_DOWN)) { | |||||
offset.y += arrowSpeed; | offset.y += arrowSpeed; | ||||
} | } | ||||
} | } | ||||
@@ -1,8 +1,6 @@ | |||||
#include "ui.hpp" | #include "ui.hpp" | ||||
// for gVg | // for gVg | ||||
#include "window.hpp" | #include "window.hpp" | ||||
// for key codes | |||||
#include <GLFW/glfw3.h> | |||||
namespace rack { | namespace rack { | ||||
@@ -516,6 +516,10 @@ bool windowIsShiftPressed() { | |||||
return glfwGetKey(gWindow, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; | return glfwGetKey(gWindow, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; | ||||
} | } | ||||
bool windowIsKeyPressed(int key) { | |||||
return glfwGetKey(gWindow, key) == GLFW_PRESS; | |||||
} | |||||
Vec windowGetWindowSize() { | Vec windowGetWindowSize() { | ||||
int width, height; | int width, height; | ||||
glfwGetWindowSize(gWindow, &width, &height); | glfwGetWindowSize(gWindow, &width, &height); | ||||