glfwSetWindowCloseCallback function

GLFWwindowclosefun glfwSetWindowCloseCallback(
  1. Pointer<GLFWwindow> window,
  2. GLFWwindowclosefun callback
)

! @brief 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.

@paramin window The window whose callback to set. @paramin callback The new callback, or NULL to remove the currently set callback. @return The previously set callback, or NULL if no callback was set or the library had not been initialized(@ref intro_init).

@callback_signature @code void function_name(GLFWwindow* window) @endcode For more information about the callback parameters, see the function pointer type(@ref GLFWwindowclosefun).

@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

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

@ingroup window

GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback)

Implementation

GLFWwindowclosefun glfwSetWindowCloseCallback(
    Pointer<GLFWwindow> window, GLFWwindowclosefun callback) {
  final glfwSetWindowCloseCallbackLookupFunction = libglfw.lookupFunction<
      GLFWwindowclosefun Function(
          Pointer<GLFWwindow> window, GLFWwindowclosefun callback),
      GLFWwindowclosefun Function(Pointer<GLFWwindow> window,
          GLFWwindowclosefun callback)>('glfwSetWindowCloseCallback');
  return glfwSetWindowCloseCallbackLookupFunction(window, callback);
}