Widget Lifecycle
To manage the complexity of the asynchronous web, every widget follows a strict lifecycle, which you can check via the WidgetState property.
- wsCreating: This is the state during the constructor. At this stage, the DOM element exists in memory but has not yet been fully styled or attached to the DOM. If you set MyWidget.Left := 10 here, the value is stored in a private field (e.g., fLeft) to be applied later.
- wsReady: This is the "live" state. The element is in the DOM and fully initialized. The constructor calls ApplyPropertyCache, which writes all the cached values (like fLeft) to the element's actual CSS styles. It then calls the virtual ObjectReady method, which you can override for any setup logic that must run after the widget is fully live.
- wsDestroying: This is the state during the destructor. The widget detaches its Handle from the DOM, unregisters itself from the TQTXWidgetRegistry, and frees its children.