Skip to main content

Tooltip

This component creates a pop-up tooltip when hovering over its parent. Create a child object, create this Tooltip component, and use its transform to position it.

Component Breakdown



Render OrderSets the renderOrder for the visuals of the element.
TipSets the text of the Tooltip.

Code Example

import { TextInputField } from 'SpectaclesUIKit.lspkg/Scripts/Components/TextInputField/TextInputField';
import { Tooltip } from 'SpectaclesUIKit.lspkg/Scripts/Tooltip';

/**
* Example script for the Tooltip component.
* It creates a text input field and a tooltip and sets the tooltip's text and position.
*/

@component
export class ExampleTooltipScript extends BaseScriptComponent {
onAwake() {
const textInputField = this.sceneObject.createComponent(
TextInputField.getTypeName()
);
textInputField.placeholderText = 'Enter your name';
textInputField.inputType = 'default';
textInputField.size = new vec3(15, 3, 1);

const tooltipObject = global.scene.createSceneObject('Tooltip');
tooltipObject.setParent(this.sceneObject);
const tooltip = tooltipObject.createComponent(Tooltip.getTypeName());
tooltip.tip = 'This is a tooltip';
tooltipObject.getTransform().setLocalPosition(new vec3(0, 4, 0));
}
}
Was this page helpful?
Yes
No