WidgetGetName

Syntax

Name$ = WidgetGetName(Widget)

Description

Retrieves the name currently assigned to the specified ProGUI widget.

Parameters

Widget
The handle of the ProGUI widget whose name is to be retrieved.

Return Value

Returns the name of the widget as a string. Returns an empty string ("") if the widget has no assigned name or if the provided widget handle is invalid.

Remarks

Widget names in ProGUI are primarily used as unique identifiers for the skinning engine, equivalent to the ID selector (#name) in standard CSS. This name is typically applied using the WidgetSetName() function shortly after the widget is created.

If you change a widget’s name, its internal class path hash is rebuilt, which allows the skinning engine to automatically re-evaluate and apply properties tied to its new name identifier.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyWindow = CreateWindow(0, 0, 300, 200, "WidgetGetName Example")

If MyWindow
  ; Create a standard widget
  MyWidget = CreateWidget(20, 20, 150, 40)
  
  ; Retrieve the initial name (will be an empty string)
  InitialName$ = WidgetGetName(MyWidget)
  Debug "Initial Name: '" + InitialName$ + "'"

  ; Assign a unique name to the widget (useful for #ID skin styling)
  WidgetSetName(MyWidget, "SubmitButton")

  ; Retrieve the newly assigned name
  UpdatedName$ = WidgetGetName(MyWidget)
  Debug "Updated Name: '" + UpdatedName$ + "'"
  
  WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)

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

StopProGUI()

See Also

WidgetSetName, WidgetSetClass, WidgetGetClass, CreateWidget

Supported OS

Windows, Linux