# gShow

Definition: | include xpGUI.e gShow(gdx id, integer x=XPG_CURRENT, y=XPG_CURRENT)
Description: | Displays a dialog, optionally in a given position on the screen. id: a result from gDialog() [use gPopupMenu for menus] x, y: top left corner in pixels, or one of the predefined constants listed below. Equivalent to gSetAttribute(id,"VISIBLE",true) when used on individual elements and sub-containers.
pwa/p2js: | Supported.
Comments: | Optionally the following definitions can also be used for x (instead of a specific pixel co-ordinate): XPG_LEFT: Positions the dialog on the left edge of the screen XPG_CENTER: Horizontally centralizes the dialog on the screen XPG_RIGHT: Positions the dialog on the right edge of the screen XPG_MOUSEPOS: Positions the left/right edge of the dialog on the mouse position XPG_CENTERPARENT: Horizontally centralizes the dialog relative to its parent XPG_CURRENT: use the current position of the dialog, XPG_CENTER if not known. XPG_LEFTPARENT: Positions the element on the left border of its parent. Not valid for menus. XPG_RIGHTPARENT: Positions the element on the right border of its parent. Not valid for menus. and likewise the following definitions can also be used for y (instead of a specific pixel co-ordinate): XPG_TOP: Positions the dialog on the top edge of the screen XPG_CENTER: Vertically centralizes the dialog on the screen XPG_BOTTOM: Positions the dialog on the base of the screen XPG_MOUSEPOS: Positions the top/bottom edge of the dialog on the mouse position XPG_CENTERPARENT: Vertically centralizes the dialog relative to its parent XPG_CURRENT: use the current position of the dialog, XPG_CENTER if not known. XPG_TOPPARENT: Positions the element on the top border of its parent. Not valid for menus. XPG_BOTTOMPARENT: Positions the element on the base of its parent. Not valid for menus. Note that XPG_CENTRE is for gCanvasText() and the wrong constant, treated as 0 here (since it is) which in this case is taken to mean top/left, as in the absolute screen position {0,0}. Invokes gMap() automatically, when needed. See the PLACEMENT attribute for other position and show options. When XPG_CURRENT is used at the first time the dialog is shown then it is replaced by XPG_CENTERPARENT. When XPG_CENTERPARENT is used but no parent is defined then it is treated the same as XPG_CENTER. When either x or y is XPG_MOUSEPOS they must both be. The window is positioned such that the top left corner is at the mouse pointer co-ordinates, unless that would exceed the right hand side of the screen in which case it is positioned with the right edge touching the mouse pointer, and/or if it would drop below the bottom of the screen the dialog is positioned above the mouse pointer, in other words one of the four corners of the window will be on the mouse pointer. Should the window exceed half the height or width of the screen, then from certain positions the top left corner of the window may end up off-screen, in which case either use a smaller window or constrain where the mouse can be when this can happen towards the edges and away from the centre of the screen - so for instance you could still have a ridiculously huge popup when clicking on the properties of a monopoly board. For anything fancier you could always just calculate the co-ordinates yourself, it’s not exactly hard. The main screen size does not include additional monitors. This function can be executed more than once for the same dialog. This will make the dialog be placed above all other dialogs in the application, changing its Z-order, and update its position and/or size on screen. IMPORTANT: Calling gShow() for a visible dialog previously shown with bModal:=true does nothing.
Example: |
    gShow(dlg)
See Also: | gHide, gMap
Technicalia | Unlike the C API and pGUI and thanks to optional parameters there is no need for a separate IupShowXY() or gShowXY() routine.