| @@ -1,5 +1,5 @@ | |||||
| VERSION ?= dev | VERSION ?= dev | ||||
| FLAGS += -DVERSION=$(VERSION) | |||||
| FLAGS += -DVERSION=$(VERSION) -DVERSION_$(subst .,_,$(VERSION)) | |||||
| # Generate dependency files alongside the object files | # Generate dependency files alongside the object files | ||||
| FLAGS += -MMD | FLAGS += -MMD | ||||
| @@ -112,7 +112,7 @@ struct Widget { | |||||
| virtual void onMouseEnter() {} | virtual void onMouseEnter() {} | ||||
| /** Called when another widget begins responding to `onMouseMove` events */ | /** Called when another widget begins responding to `onMouseMove` events */ | ||||
| virtual void onMouseLeave() {} | virtual void onMouseLeave() {} | ||||
| virtual void onFocus() {} | |||||
| virtual bool onFocus() {return false;} | |||||
| virtual void onDefocus() {} | virtual void onDefocus() {} | ||||
| virtual bool onFocusText(int codepoint) {return false;} | virtual bool onFocusText(int codepoint) {return false;} | ||||
| virtual bool onFocusKey(int key) {return false;} | virtual bool onFocusKey(int key) {return false;} | ||||
| @@ -409,7 +409,7 @@ struct TextField : OpaqueWidget { | |||||
| Widget *onMouseDown(Vec pos, int button); | Widget *onMouseDown(Vec pos, int button); | ||||
| bool onFocusText(int codepoint); | bool onFocusText(int codepoint); | ||||
| bool onFocusKey(int scancode); | bool onFocusKey(int scancode); | ||||
| void onFocus(); | |||||
| bool onFocus(); | |||||
| void insertText(std::string newText); | void insertText(std::string newText); | ||||
| }; | }; | ||||
| @@ -152,14 +152,16 @@ void ModuleWidget::draw(NVGcontext *vg) { | |||||
| } | } | ||||
| Widget *ModuleWidget::onMouseMove(Vec pos, Vec mouseRel) { | Widget *ModuleWidget::onMouseMove(Vec pos, Vec mouseRel) { | ||||
| // 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 (!guiIsModPressed() && !guiIsShiftPressed()) { | |||||
| gRackWidget->deleteModule(this); | |||||
| this->finalizeEvents(); | |||||
| delete this; | |||||
| // Kinda sketchy because events will be passed further down the tree | |||||
| return NULL; | |||||
| 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. | |||||
| if (glfwGetKey(gWindow, GLFW_KEY_DELETE) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_BACKSPACE) == GLFW_PRESS) { | |||||
| if (!guiIsModPressed() && !guiIsShiftPressed()) { | |||||
| gRackWidget->deleteModule(this); | |||||
| this->finalizeEvents(); | |||||
| delete this; | |||||
| // Kinda sketchy because events will be passed further down the tree | |||||
| return NULL; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| return OpaqueWidget::onMouseMove(pos, mouseRel); | return OpaqueWidget::onMouseMove(pos, mouseRel); | ||||
| @@ -59,12 +59,16 @@ void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods) { | |||||
| if (w != gFocusedWidget) { | if (w != gFocusedWidget) { | ||||
| if (gFocusedWidget) { | if (gFocusedWidget) { | ||||
| // onDefocus | |||||
| w->onDefocus(); | w->onDefocus(); | ||||
| } | } | ||||
| gFocusedWidget = NULL; | |||||
| if (w) { | if (w) { | ||||
| w->onFocus(); | |||||
| // onFocus | |||||
| if (w->onFocus()) { | |||||
| gFocusedWidget = w; | |||||
| } | |||||
| } | } | ||||
| gFocusedWidget = w; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -103,9 +103,10 @@ bool TextField::onFocusKey(int key) { | |||||
| return true; | return true; | ||||
| } | } | ||||
| void TextField::onFocus() { | |||||
| bool TextField::onFocus() { | |||||
| begin = 0; | begin = 0; | ||||
| end = text.size(); | end = text.size(); | ||||
| return true; | |||||
| } | } | ||||
| void TextField::insertText(std::string newText) { | void TextField::insertText(std::string newText) { | ||||