IUP-Go Documentation 4.0

IupPopup

Shows a dialog or menu and restricts user interaction only to the specified element. It is the equivalent of creating a Modal dialog is some toolkits.

If another dialog is shown after IupPopup using IupShow, then its interaction will not be inhibited. Every IupPopup call creates a new popup level that inhibits all previous dialogs interactions, but does not disable new ones (even if they were disabled by the Popup, calling IupShow will re-enable the dialog because it will change its popup level). The popup levels must be closed in the reverse order they were created or unpredictable results will occur.

For a dialog, this function will only return the control to the application after a callback returns IUP_CLOSE, IupExitLoop is called, or when the popup dialog is hidden, for example using IupHide. For a menu it returns automatically after a menu item is selected. If a menu item callback returns IUP_CLOSE, it also ends the current popup level dialog.

Parameters/Return

int IupPopup(Ihandle *ih, int x, int y);

ih: Identifier of a dialog or a menu.
x: horizontal position of the top-left corner of the window or menu, relative to the origin of the main screen. The following definitions can also be used:

y: vertical position of the top-left corner of the window or menu, relative to the origin of the main screen. The following definitions can also be used:

Returns: IUP_NOERROR if successful. Returns IUP_INVALID if not a dialog or menu. If there was error returns IUP_ERROR.

Notes

It will call IupMap for the element.

The x and y values are the same as returned by the SCREENPOSITION attribute.

IUP_MOUSEPOS position is the same as returned by the CURSORPOS global attribute.

See the PLACEMENT attribute for other position and show options.

When IUP_CENTERPARENT is used but PARENTDIALOG is not defined, then it is replaced by IUP_CENTER.

When IUP_CURRENT is used at the first time the dialog is shown, then it will be replaced by IUP_CENTERPARENT.

The main screen area does not include additional monitors.

IupPopup works just like IupShowXY, but it inhibits interaction with other dialogs that are visible and interrupts the processing until IUP_CLOSE is returned in a callback, IupExitLoop is called, or the popup dialog is hidden. The dialog is modal. It is not destroyed when the popup ends. To destroy the dialog, IupDestroy must be called.

The MODAL attribute of the dialog will be changed internally to return YES.

The global callbacks GLOBALENTERMODAL_CB and GLOBALLEAVEMODAL_CB, set with IupSetFunction, are called when a dialog becomes modal and when it stops being modal.

int function(int popup_level);

popup_level: the popup level before the change, 1 when no dialog is modal.

In GTK and Motif, the inactive dialogs will still be moveable, resizable and changeable their Z-order. Although their contents will be inactive, the keyboard will be disabled, and they cannot be closed from the close box.

When called for an already visible dialog (modal or not) it will update its position and PLACEMENT. If the already visible dialog is not modal, then it will become modal and processing will be interrupted as a regular IupPopup. If the already visible dialog is modal, then the function returns, and it will NOT interrupt processing, the dialog still will remain MODAL.

Examples

Ihandle* menu = IupMenu(
  IupMenuItem("Cut"),
  IupMenuItem("Copy"),
  IupSetAttributes(IupMenuItem("Paste"), "ACTIVE=NO"),
  IupMenuSeparator(),
  IupMenuItem("Select All"),
  NULL);

IupPopup(menu, IUP_MOUSEPOS, IUP_MOUSEPOS);
IupDestroy(menu);
GTK Qt Win32 macOS

See Also

IupShowXY, IupShow, IupHide, IupMap, IupDialog