COMPONENT REFERENCETray service

Tooltip

Attach delayed contextual help to a target control.

kind: tooltipJavaScript + C#Implemented

What it does

Attach delayed contextual help to a target control.

This is a component tray service. It appears below the form and does not take a canvas rectangle.

Set it up

  1. Add Tooltip from Toolbox.
  2. Set its Name to sample for the examples below. Names are case-sensitive.
  3. Configure the component-specific properties below.
  4. Open the Events inspector to add a handler: methods go in event.js, imports and subscriptions in script.js. Right-click View Events or View Script to edit either file. Use View CSS for scoped styles and View Custom Properties for JSON values.
  5. Save sources, save the project, and open a fresh Preview. Scripts execute in Preview.

JavaScript example

These examples use supported inline subscriptions for brevity. The Events inspector can generate separate class methods in event.js instead.

Add a TextBox named nameInput. This tray component targets a visual control; initialDelay and showDuration use milliseconds.

forma.on("Load", () => {
  forma.set("sample", "targetId", "nameInput");
  forma.set("sample", "text", "Use your full name.");
  forma.set("sample", "placement", "bottom");
});

Component properties

FieldInspector keyEditorAccepted values / rangeRuntime key
TargettargetIdtarget—targetId
Initial delay (ms)initialDelaynumber0–10000initialDelay
Duration (ms)showDurationnumber500–60000showDuration
Placementplacementselecttop, bottom, left, rightplacement

Runtime property API

Use forma.get("sample", key), forma.set("sample", key, value), or forma.bind("sample", key). Read a binding with .value; write only when the Binding column permits it. Numbers and booleans must keep their types. Arrays are passed directly, not as JSON strings.

KeyValue typegetsetBindingMeaning / restrictions
textstringYesYesRead/writeDisplay text; use value to read live text input.
enabledbooleanYesYesRead/writeEnabled
visiblebooleanYesYesRead/writeSupported runtime property.
tagstringYesYesRead/writeTag
targetIdstringYesYesRead/writeVisual control Name or ID; reads return its stable ID.
initialDelaynumberYesYesRead/writeRange 0–10000. Invalid types are rejected; numeric values clamp.
showDurationnumberYesYesRead/writeRange 500–60000. Invalid types are rejected; numeric values clamp.
placement"top" | "bottom" | "left" | "right"YesYesRead/writePlacement

Set commands cross the native bridge asynchronously. An immediate get after set may return the previous value. Observe a binding or use the assigned value locally. Getter arrays are copies. Geometry is configured model geometry; layout and CSS may override rendered bounds.

Shared inspector fields

FieldInspector keyEditorAccepted values / rangeRuntime key
Namenametext—Designer only
ID (read-only)idtext—Designer only
Text / Titletexttext—text
Tagtagtext—tag
Lockedlockedcheckbox—Designer only
Enabledenabledcheckbox—enabled

Events and lifecycle

Component hooks: Relevant DOM events and shared lifecycle events.

Tray services have lifecycle events even without a visible control. Event names are case-insensitive. Put handlers on the component producing the event; a Timer Tick handler belongs to the Timer, or can be observed through forma.root.on("Tick", handler). See the event guide for payloads, validation, cleanup, and startup order.

Property-change payload

All components can report PropertyChanged for changed projected runtime properties. Handlers expose source/subscriber component handles; native DOM targets remain available. Input/Change can supply typed property values, while Click normally supplies identity without a property/value pair.

forma.on("PropertyChanged", ({ source, property, value, previousValue, origin }) => {
  console.log(source.name, property, previousValue, "→", value, origin);
});

Use forma.root.on(...) to observe the active form, and event.toJSON() for portable logs. Subscriptions return unsubscribe and are cleaned up with the subscribing script.

C# example

Use this in a configured Forma C# host, not in script.js. The renderer is your host's WebView2Renderer instance.

var sample = new Forma.Core.Controls.Tooltip
{
    Name = "sample"
};
await renderer.RenderAsync(sample);

C# model reference

These are Core constructor defaults, not necessarily the Builder’s drop-time styles or size. Appearance fields belong to Builder Appearance. C# events are not all forwarded to JavaScript.

PropertyC# typeConstructor defaultWritable
TargetIdString""Yes
InitialDelayInt32500Yes
ShowDurationInt325000Yes
PlacementString"top"Yes
NameStringnullYes
LayoutSlotInt321Yes
XNullable1`nullYes
YNullable1`nullYes
TextString"Helpful tip"Yes
ValueStringnullYes
PlaceholderStringnullYes
LabelStringnullYes
ControlTypeString"tooltip"No

Core methods: GetRenderState(), HandleRuntimeEvent(runtimeEvent), Add(child), Insert(index, child), MoveChild(child, index), Remove(child).

Core events: ChildAdded, ChildRemoved, PropertyChanged.

Search components, properties, and guides.

↑↓ navigate Enter open Esc close