sdlSetWindowMouseGrab function

bool sdlSetWindowMouseGrab(
  1. Pointer<SdlWindow> window,
  2. bool grabbed
)

Set a window's mouse grab mode.

Mouse grab confines the mouse cursor to the window.

\param window the window for which the mouse grab mode should be set. \param grabbed this is true to grab mouse, and false to release. \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety This function should only be called on the main thread.

\since This function is available since SDL 3.1.3.

\sa SDL_GetWindowMouseRect \sa SDL_SetWindowMouseRect \sa SDL_SetWindowMouseGrab \sa SDL_SetWindowKeyboardGrab

extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, bool grabbed)

Implementation

bool sdlSetWindowMouseGrab(Pointer<SdlWindow> window, bool grabbed) {
  final sdlSetWindowMouseGrabLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<SdlWindow> window, Uint8 grabbed),
      int Function(
          Pointer<SdlWindow> window, int grabbed)>('SDL_SetWindowMouseGrab');
  return sdlSetWindowMouseGrabLookupFunction(window, grabbed ? 1 : 0) == 1;
}