glfwSetWindowCloseCallback

Sets the close callback for the specified window.

This function sets the close callback of the specified window, which is called when the user attempts to close the window, for example by clicking the close widget in the title bar.

The close flag is set before this callback is called, but you can modify it at any time with @ref glfwSetWindowShouldClose.

The close callback is not triggered by @ref glfwDestroyWindow.

extern (C) @nogc nothrow __gshared
glfwSetWindowCloseCallback

Parameters

window GLFWwindow*

The window whose callback to set.

callback GLFWwindowclosefun

The new callback, or null to remove the currently set callback.

Return Value

The previously set callback, or null if no callback was set or the library had not been initialized.

@callback_signature

void function_name(GLFWwindow* window)

For more information about the callback parameters, see the function pointer type.

Errors: Possible errors include @ref GLFW_NOT_INITIALIZED.

@remark @macos Selecting Quit from the application menu will trigger the close callback for all windows.

Thread Safety

This function must only be called from the main thread.

@sa @ref window_close

Meta

Since

Added in version 2.5. @glfw3 Added window handle parameter and return value.

Ingroup: window