Fix uncaptureCallback

This commit is contained in:
MrLetsplay 2022-11-07 09:10:54 +01:00
parent 6c88bcd385
commit 6bf2e12b08
2 changed files with 5 additions and 1 deletions

View File

@ -112,6 +112,7 @@ KeyboardCapture captureKeyboardInput(KeyCharCallback charCallback, KeyCallback k
bool uncaptureKeyboardInput(KeyboardCapture capture) { bool uncaptureKeyboardInput(KeyboardCapture capture) {
if(capture == KEK_INVALID_ID || capture != kekData.activeKeyboardCapture.id) return false; if(capture == KEK_INVALID_ID || capture != kekData.activeKeyboardCapture.id) return false;
kekData.activeKeyboardCapture.uncaptureCallback();
kekData.activeKeyboardCapture = { kekData.activeKeyboardCapture = {
KEK_INVALID_ID, KEK_INVALID_ID,
KeyCharCallback(), KeyCharCallback(),

View File

@ -22,6 +22,7 @@ void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods, v
} }
void onButtonClick(void *data) { void onButtonClick(void *data) {
button->color = Colors::RED;
capture = Input::captureKeyboardInput(KeyCharCallback([](GLFWwindow *window, unsigned int codepoint, void *data) { capture = Input::captureKeyboardInput(KeyCharCallback([](GLFWwindow *window, unsigned int codepoint, void *data) {
std::u32string str = Unicode::convertStdToU32(button->text->getText()); std::u32string str = Unicode::convertStdToU32(button->text->getText());
if(codepoint == KEK_INPUT_DELETE) { if(codepoint == KEK_INPUT_DELETE) {
@ -34,7 +35,9 @@ void onButtonClick(void *data) {
if(key == GLFW_KEY_ENTER && action == GLFW_PRESS) { if(key == GLFW_KEY_ENTER && action == GLFW_PRESS) {
Input::uncaptureKeyboardInput(capture); Input::uncaptureKeyboardInput(capture);
} }
}, nullptr), Callable()); }, nullptr), Callable([](void *data) {
button->color = Colors::WHITE;
}, nullptr));
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {