import{_ as t,a,b as o,ag as i}from"./chunks/framework.BcrMLAmg.js";const m=JSON.parse('{"title":"VisualElement","description":"","frontmatter":{},"headers":[],"relativePath":"references/elements/VisualElement.md","filePath":"references/elements/VisualElement.md","lastUpdated":1757844696000}'),r={name:"references/elements/VisualElement.md"};function n(d,e,l,s,h,u){return o(),a("div",null,e[0]||(e[0]=[i('
This is the visual element class. It serves as the base class for all visual UI elementsand provides core functionality for positioning, sizing, colors, and rendering.
Extends: BaseElement
| Property | Type | Default | Description |
|---|---|---|---|
| x | number | 1 | The horizontal position relative to parent |
| y | number | 1 | The vertical position relative to parent |
| z | number | 1 | The z-index for layering elements |
| width | number | 1 | The width of the element |
| height | number | 1 | The height of the element |
| background | color | black | The background color |
| foreground | color | white | The text/foreground color |
| clicked | boolean | false | Whether the element is currently clicked |
| hover | boolean | false | Whether the mouse is currently hover over the element (Craftos-PC only) |
| backgroundEnabled | boolean | true | Whether to render the background |
| focused | boolean | false | Whether the element has input focus |
| visible | boolean | true | Whether the element is visible |
| ignoreOffset | boolean | false | Whether to ignore the parent's offset |
| Event | Parameters | Description |
|---|---|---|
| onClick | button string, x number, y number | Fired on mouse click |
| Method | Returns | Description |
|---|---|---|
| VisualElement:isInBounds | boolean | Checks if point is within bounds |
| VisualElement:calculatePosition | number, number | Calculates the position of the element |
| VisualElement:getAbsolutePosition | number, number | Returns the absolute position of the element |
| VisualElement:getRelativePosition | number, number | Returns the relative position of the element |
| VisualElement:prioritize | VisualElement | Prioritizes the element by moving it to the top of its parent's children |
Checks if the specified coordinates are within the bounds of the element
x number The x position to checky number The y position to checkboolean isInBounds Whether the coordinates are within the bounds of the elementCalculates the position of the element relative to its parent
number x The x positionnumber y The y positionReturns the absolute position of the element or the given coordinates.
x (optional) number x positiony (optional) number y positionnumber x The absolute x positionnumber y The absolute y positionReturns the relative position of the element or the given coordinates.
x (optional) number x positiony (optional) number y positionnumber x The relative x positionnumber y The relative y positionThis function is used to prioritize the element by moving it to the top of its parent's children. It removes the element from its parent and adds it back, effectively changing its order.
VisualElement self The VisualElement instance