glfwSetCharCallback function

GLFWcharfun glfwSetCharCallback(
  1. Pointer<GLFWwindow> window,
  2. GLFWcharfun callback
)

! @brief Sets the Unicode character callback.

This function sets the character callback of the specified window, which is called when a Unicode character is input.

The character callback is intended for Unicode text input. As it deals with characters, it is keyboard layout dependent, whereas the key callback(@ref glfwSetKeyCallback) is not. Characters do not map 1:1 to physical keys, as a key may produce zero, one or more characters. If you want to know whether a specific physical key was pressed or released, see the key callback instead.

The character callback behaves as system text input normally does and will not be called if modifier keys are held down that would prevent normal text input on that platform, for example a Super (Command) key on macOS or Alt key on Windows.

@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, unsigned int codepoint) @endcode For more information about the callback parameters, see the function pointer type(@ref GLFWcharfun).

@errors Possible errors include @ref GLFW_NOT_INITIALIZED.

@thread_safety This function must only be called from the main thread.

@sa @ref input_char

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

@ingroup input

GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback)

Implementation

GLFWcharfun glfwSetCharCallback(
    Pointer<GLFWwindow> window, GLFWcharfun callback) {
  final glfwSetCharCallbackLookupFunction = libglfw.lookupFunction<
      GLFWcharfun Function(Pointer<GLFWwindow> window, GLFWcharfun callback),
      GLFWcharfun Function(Pointer<GLFWwindow> window,
          GLFWcharfun callback)>('glfwSetCharCallback');
  return glfwSetCharCallbackLookupFunction(window, callback);
}