# Control

### Main Loop

xpGUI is an event-oriented interface system, that uses an event loop "waiting" for the user to interact with the application.
For this loop to occur, the application must call the gMainLoop() routine, which is actually a null-op under pwa/p2js, since that relies on the browser’s event loop. The event loop goes idle properly, rather than needlessly chewing up 100% CPU time.
The following routines are used to control startup, shutdown, and everything inbetween:

gShow | Displays a dialog [in a specified position] on the screen.
gHide | Hides an interface element/dialog.
gMap | (optional) Creates (maps) the native interface objects corresponding to the given (abstract) xpGUI interface elements.
gRedraw | Redraw and/or update the size and layout of all controls in the same dialog.
gSetFocus, gGetFocus | Set keyboard focus to a specified interface element. Find out which control has said focus.
gMainLoop | Start the main event processing loop/user interaction
gClipboard | Creates an element that allows access to the clipboard.
gTimer | Creates a timer