tp.Component
tp.Component is the base class for Tripous objects that wrap an HTML element.
It inherits from tp.Object, so it has the Tripous event mechanism, and adds a
Handle property that points to a real DOM element.
Most visual Tripous classes are components, directly or indirectly. Controls such as
tp.Button, tp.TextBox, list controls, panels, menus, and grid panels all
build on this idea: a JavaScript object owns or wraps an element, exposes useful properties, and
can send Tripous events.
This page stays away from construction lifecycle details. It only shows how a programmer can use an already-created component: read its state, change text and tooltip, toggle visibility, change CSS, focus it, and work with child elements and child components.
Wrap existing markup
A component may wrap an existing HTML element. Here new tp.Component("#MarkupBox")
creates a component around the markup below.
Visibility and style
Visible controls display. CssClasses replaces
class names. CssText and tp.StyleProp() can be used for
style values such as height.
Focus and tab index
A component can focus its handle with Focus(). A TabIndex
of -1 keeps the element programmatically focusable without placing it
in the normal tab order.
Child elements and child components
A component can add plain child elements or child components. Count
returns direct child element count, while GetComponentList() returns
direct child components.