TQTXWidgetRegistry
This "Handle-to-Object" relationship that TQTXWidget operates with is simple and effective. But how does the system work in reverse? When a user clicks on an HTML element, how does the system know which Pascal TQTXWidget object is responsible for it? How can you go from knowing a handle, to getting the object instance for the widget?
This is solved by the TQTXWidgetRegistry. When a TQTXWidget is created, it is registered with a unique ID, which is also written to the DOM element as a data-idx attribute. When a DOM event occurs, the system can read this attribute from the element, look it up in the registry, and find the exact Pascal object instance that needs to handle the event.
It is very clever and powerful stuff if you use it right.