From b28769207e350d3a376c6e0c646cd1ef80031226 Mon Sep 17 00:00:00 2001 From: nearnshaw Date: Mon, 9 Dec 2024 17:31:12 -0300 Subject: [PATCH] UI button events clean up & new content --- .../creator/sdk7/2d-ui/ui_button_events.md | 253 +++++++++++------- 1 file changed, 149 insertions(+), 104 deletions(-) diff --git a/content/creator/sdk7/2d-ui/ui_button_events.md b/content/creator/sdk7/2d-ui/ui_button_events.md index 46f295e0..a6d7c7ba 100644 --- a/content/creator/sdk7/2d-ui/ui_button_events.md +++ b/content/creator/sdk7/2d-ui/ui_button_events.md @@ -9,24 +9,11 @@ url: /creator/development-guide/sdk7/ui-button-events/ weight: 3 --- -To make a button in your UI, create a `Button` UI element. The button must have the following: +To make a button in your UI, create a `Button` UI element with the following properties: - `value`: A string with the text to display on the button. - -It can also have: - - `onMouseDown`: A callback function that runs every time the user pushes the pointer button on the entity. - {{< hint warning >}} - **📔 Note**: To click on a UI component, players must first unlock the cursor from the view control. They do this by pressing the _right mouse button_ and keeping it pressed, or by hitting `Esc`. - {{< /hint >}} -- `onMouseUp`: A similar callback function that runs every the pointer button is raised while pointing at the entity. -- `variant`: Use this property to set the style of the button as one of the defaults. `primary` and `secondary` are available. -- `disabled`: Boolean to set a button disabled. When disabled is set to _true_, the `onMouseDown` and `onMouseUp` actions are no longer called. Also the `apha` value of the color of both the text and the backgroun is halved, so the button is "grayed-out" and stands out less. -- `color`: Background color of the button. -- `font`: Font of the text on the button. -- `textAlign`: Alignment of the text inside the button - `uiTransform`: Positioning properties of the UI element. -- `uiBackground`: Set the color or texture of the UI element. The following example shows how to create a clickable UI button. @@ -34,14 +21,13 @@ The following example shows how to create a clickable UI button. import { ReactEcsRenderer } from '@dcl/sdk/react-ecs' ReactEcsRenderer.setUiRenderer(() => ( -