diff --git a/src/raylib.h b/src/raylib.h index 4e989795e..cea71083c 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -502,7 +502,8 @@ typedef enum { FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X - FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D) + FLAG_INTERLACED_HINT = 0x00010000, // Set to try enabling interlaced video format (for V3D) + FLAG_DISABLE_EXIT_KEY = 0x00004000 // Set to disable the exit key to close the window. } ConfigFlags; // Trace log level diff --git a/src/rcore.c b/src/rcore.c index dbcf670bb..89c48ea56 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -5253,7 +5253,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i } // Check the exit key to set close window - if ((key == CORE.Input.Keyboard.exitKey) && (action == GLFW_PRESS)) glfwSetWindowShouldClose(CORE.Window.handle, GLFW_TRUE); + if ((CORE.Window.flags & FLAG_DISABLE_EXIT_KEY) == 0 && (key == CORE.Input.Keyboard.exitKey) && (action == GLFW_PRESS)) glfwSetWindowShouldClose(CORE.Window.handle, GLFW_TRUE); #if defined(SUPPORT_SCREEN_CAPTURE) if ((key == GLFW_KEY_F12) && (action == GLFW_PRESS)) @@ -5882,7 +5882,7 @@ static void ProcessKeyboard(void) if (keysBuffer[i] == 0x1b) { // Check if ESCAPE key has been pressed to stop program - if (bufferByteCount == 1) CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] = 1; + if (bufferByteCount == 1 && (CORE.Window.flags & FLAG_DISABLE_EXIT_KEY) == 0) CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] = 1; else { if (keysBuffer[i + 1] == 0x5b) // Special function key @@ -5957,7 +5957,7 @@ static void ProcessKeyboard(void) } // Check exit key (same functionality as GLFW3 KeyCallback()) - if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true; + if ((CORE.Window.flags & FLAG_DISABLE_EXIT_KEY) == 0 && CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true; #if defined(SUPPORT_SCREEN_CAPTURE) // Check screen capture key (raylib key: KEY_F12) @@ -6278,7 +6278,7 @@ static void PollKeyboardEvents(void) } #endif - if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true; + if ((CORE.Window.flags & FLAG_DISABLE_EXIT_KEY) == 0 && CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true; TRACELOGD("RPI: KEY_%s ScanCode: %4i KeyCode: %4i", event.value == 0 ? "UP":"DOWN", event.code, keycode); }