SDL Wiki

SDL_CreatePopupWindow

Create a child popup window of the specified parent window.

Header File

Defined in <SDL3/SDL_video.h>

Syntax

SDL_Window * SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, SDL_WindowFlags flags);

Function Parameters

SDL_Window * parent the parent of the window, must not be NULL.
int offset_x the x position of the popup window relative to the origin of the parent.
int offset_y the y position of the popup window relative to the origin of the parent window.
int w the width of the window.
int h the height of the window.
SDL_WindowFlags flags SDL_WINDOW_TOOLTIP or SDL_WINDOW_POPUP_MENU, and zero or more additional SDL_WindowFlags OR'd together.

Return Value

(SDL_Window *) Returns the window that was created or NULL on failure; call SDL_GetError() for more information.

Remarks

The window size is a request and may be different than expected based on the desktop layout and window manager policies. Your application should be prepared to handle a window of any size.

The flags parameter must contain at least one of the following:

The following flags are not relevant to popup window creation and will be ignored:

The following flags are incompatible with popup window creation and will cause it to fail:

The parent parameter must be non-null and a valid window. The parent of a popup window can be either a regular, toplevel window, or another popup window.

Popup windows cannot be minimized, maximized, made fullscreen, raised, flash, be made a modal window, be the parent of a toplevel window, or grab the mouse and/or keyboard. Attempts to do so will fail.

Popup windows implicitly do not have a border/decorations and do not appear on the taskbar/dock or in lists of windows such as alt-tab menus.

By default, popup window positions will automatically be constrained to keep the entire window within display bounds. This can be overridden with the SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN property.

By default, popup menus will automatically grab keyboard focus from the parent when shown. This behavior can be overridden by setting the SDL_WINDOW_NOT_FOCUSABLE flag, setting the SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN property to false, or toggling it after creation via the SDL_SetWindowFocusable() function.

If a parent window is hidden or destroyed, any child popup windows will be recursively hidden or destroyed as well. Child popup windows not explicitly hidden will be restored when the parent is shown.

Thread Safety

This function should only be called on the main thread.

Version

This function is available since SDL 3.2.0.

See Also


CategoryAPI, CategoryAPIFunction, CategoryVideo


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.