|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
#include "rendering/Window.h"
|
|
|
|
|
|
-Window::Window(TextInput& textInput, const WindowOptions& options)
|
|
|
+Window::Window(TextInput*& textInput, const WindowOptions& options)
|
|
|
: textInput(textInput), window(nullptr) {
|
|
|
glfwDefaultWindowHints();
|
|
|
glfwWindowHint(GLFW_VISIBLE, 0);
|
|
@@ -89,13 +89,18 @@ void Window::keyCallback(GLFWwindow* w, int key, int scancode, int action,
|
|
|
int mods) {
|
|
|
void* p = glfwGetWindowUserPointer(w);
|
|
|
if(p != nullptr) {
|
|
|
- static_cast<Window*>(p)->textInput.onKeyEvent(key, scancode, action,
|
|
|
- mods);
|
|
|
+ TextInput* input = static_cast<Window*>(p)->textInput;
|
|
|
+ if(input != nullptr) {
|
|
|
+ input->onKeyEvent(key, scancode, action, mods);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
void Window::charCallback(GLFWwindow* w, unsigned int codepoint) {
|
|
|
void* p = glfwGetWindowUserPointer(w);
|
|
|
if(p != nullptr) {
|
|
|
- static_cast<Window*>(p)->textInput.onCharEvent(codepoint);
|
|
|
+ TextInput* input = static_cast<Window*>(p)->textInput;
|
|
|
+ if(input != nullptr) {
|
|
|
+ input->onCharEvent(codepoint);
|
|
|
+ }
|
|
|
}
|
|
|
}
|