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) {
if(capture == KEK_INVALID_ID || capture != kekData.activeKeyboardCapture.id) return false;
kekData.activeKeyboardCapture.uncaptureCallback();
kekData.activeKeyboardCapture = {
KEK_INVALID_ID,
KeyCharCallback(),

View File

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