Syntax
Success = WidgetSetClass(Widget, ClassName$)Description
Assigns a class name to the specified widget. The class name is used by the skinning engine to select and apply appropriate styles from the active skin file(s).
Parameters
Widget
The handle of the ProGUI widget whose class name is to be set.
ClassName$
The class name string to assign. Class names typically follow CSS
conventions (e.g., "button", "text-input", "error-message").
Return Value
Returns #True if the class name was successfully set, or
#False if the widget handle was invalid.
Remarks
Setting or changing a widget's class name triggers an internal update of its "class path" (which includes the classes of its parent widgets in the layout hierarchy) and invalidates the widget's skin cache, potentially causing it to redraw with new styles if the active skin defines rules for the new class or class path.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Assume skin file defines styles for ".my-button" and ".my-label"
; Instead we will programatically create the styles
SkinSetValue("my-button", "", "", "background", "red")
SkinSetValue("my-label", "", "", "background", "orange")
MyWindow = CreateWindow(0, 0, 300, 200, "Widget Class 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
Widget1 = CreateWidget(0, 0, 100, 30)
WidgetSetClass(Widget1, "my-button") ; Assign button class
WidgetSetMargin(Widget1, 5)
; Add drawing handler if needed, or rely on skin
Widget2 = CreateWidget(0, 0, 150, 25)
WidgetSetClass(Widget2, "my-label") ; Assign label class
WidgetSetMargin(Widget2, 5)
; Add drawing handler if needed, or rely on skin
WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()See Also
WidgetGetClass, WidgetSetName, WidgetGetName, SkinSetValue
Supported OS
Windows, Linux