WidgetShow

Syntax

Success = WidgetShow(Widget, Visibility=#Null)

Description

Controls the visibility and layout participation of the specified widget.

Parameters

Widget
The handle of the ProGUI widget.

Visibility (optional)
Specifies the new visibility state. Default is #Null (which means show the widget normally).

#Null                          : Makes the widget visible and participate in layout.
#PG_Widget_Hide                : Hides the widget completely. It will not be drawn and will not take up space in the layout.
#PG_Widget_NoDraw              : The widget participates in layout calculations (takes up space) but is not drawn.

Return Value

Returns #True if the visibility state was successfully updated, or #False if the widget handle was invalid.

Remarks

Changing the visibility state triggers a layout update of the parent layout. Hiding a widget (`#PG_Widget_Hide`) removes it from the layout flow entirely. Using `#PG_Widget_NoDraw` reserves space for the widget but prevents it (and its children, if any) from rendering. OS Widgets are hidden using OS calls when set to `#PG_Widget_Hide`.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

Procedure ToggleWidget(Widget, EventType, *EventData, WidgetToToggle)
  Static HiddenState = #False
  HiddenState = 1 - HiddenState ; Toggle state
  If HiddenState
      WidgetShow(WidgetToToggle, #PG_Widget_Hide)
      Debug "Widget Hidden"
  Else
      WidgetShow(WidgetToToggle)
      Debug "Widget Shown"
  EndIf
EndProcedure

MyWindow = CreateWindow(0, 0, 300, 200, "WidgetShow Example", #PG_Window_Default | #PG_Window_LayoutFlex) ; Use a flex layout
LayoutFlexSetDirection(#Null, #PG_Flex_Direction_Column) ; Set the current layout flex direction
LayoutSetPadding(#Null, 10)

If MyWindow
  ; Widget to be toggled
  ToggleWidget = CreateWidget(0, 0, 150, 50)
  WidgetSetClass(ToggleWidget, "toggle-me")
  WidgetSetMargin(ToggleWidget, 5)
  ; Add drawing handler and/or skin properties

  ; Button to toggle the widget
  ToggleButton = CreateButton(0, 0, 100, 30, "Click me!")
  WidgetSetMargin(ToggleButton, 5)
  AddEventHandler(ToggleButton, #PG_Event_Action, @ToggleWidget(), ToggleWidget)

  WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

StopProGUI()

See Also

CreateWidget (with visibility flags)

Supported OS

Windows, Linux