Expand/Shrink

IupMainLoop

Definition: include pGUI.e

IupMainLoop()
Description: Executes the user interaction until a callback returns IUP_CLOSE, IupExitLoop is called, or hiding the last visible dialog.

Should you forget to call IupMainLoop, in most cases the application will simply and immediately terminate (without error).
pwa/p2js: Invalid (as per example below).
Note that pwa/p2js relies on the event loop of the browser, so this should not be called on that platform, nor should any subsequent IupDestroy(), ie those which on the desktop would naturally only occur after the window closes.
Notes: When this function is called, it will interrupt the program execution until a callback returns IUP_CLOSE, or IupExitLoop() is called, or there are no visible dialogs.

If you cascade many calls to IupMainLoop there must be a "return IUP_CLOSE" or IupExitLoop call for each cascade level, hiding all dialogs will close only one level.
Call IupMainLoopLevel to obtain the current level.

If IupMainLoop is called without any visible dialogs and no active timers, the application will hang and it will not be possible to close the main loop. The process will have to be interrupted by the system.

When the last visible dialog is hidden the IupExitLoop function is automatically called, causing the IupMainLoop to return.
To avoid that set LOCKLOOP=YES before hiding the last dialog.
Example:
include pGUI.e

IupOpen()
Ihandle main_dialog = IupDialog(IupLabel("Hello","PADDING=80x10"),"TITLE=test")
IupShow(main_dialog)
if platform()!=JS then
    IupMainLoop()
    main_dialog = IupDestroy(main_dialog)
    IupClose()
end if
See Also: IupLoopStep, IupExitLoop, IupMainLoopLevel, Guide/System Control, IDLE_ACTION, LOCKLOOP