gMainLoop
| Definition: |
include xpGUI.e
gMainLoop() |
| Description: |
Starts the main event loop, which runs until the last visible dialog is closed, and is responsible for
processing all user interaction messages such as and in particular all mouse and keyboard input.
Omitting gMainLoop() would (on desktop/Phix) cause the application to immediately terminate, without error. |
| pwa/p2js: |
Supported, but in practice completely ignored, with pwa/p2js instead relying on the event loop of the browser. Note that any final closedown processing as might be needed for desktop/Phix should be sidestepped as shown below. |
| Use: |
Usually towards the very end of a program,
gMainLoop()
if platform()!=JS then
/* closedown code for */
/* desktop/Phix, such */
/* as close files etc */
end if
The if-statement can be omitted should there be no desktop/Phix-specific closedown code, and it makes no difference should the call to gMainLoop() be within that construct, however omitting the test for JavaScript would cause any such code to be executed immediately, that is when the code is run in a browser. Alternatively any closedown code might be better off being in the close handler for the main window, quite possibly still within an if_not_javascript construct. |