Skip to content
Quetzy edited this page Jun 20, 2022 · 3 revisions

[!] Needs Update for 0.3.0 [!]

A button element creates a clickable button in the UI, with a background image (or color+border) and some content which could be a simple string like "OK", or any YUI element you want to put inside the button. Maybe don't put buttons inside your buttons though, right?

Adding a popup

TODO

Required Properties

content or bg_sprite (TODO: should also support only bg_color)

Core Properties

Property Type Default Value? Bindable? Description
content string or YUI element - yes The content is what will be rendered inside the button. This can be a simple string like OK (which will be converted to a text element) or any YUI element.
fit_to_content boolean or width/height true no By default, a button will size itself to only take up as much space as needed for the content (and padding). You can set fit_to_content to false, to take up the whole space, or to width or height to only fit horizontally/vertically. For example, you may want to set fit_to_content: height on a list of buttons, so that they all have a uniform width within their panel.
enabled boolean true yes Setting enabled to false allows you to render a button which is currently inactive. Doing so will render the button at 50% opacity, and clicking it will have no effect.
on_click {event handler} - - When the button is clicked, YUI will call the on_click event handler. See Events. NOTE: button does not yet use the events shared property, this will change in the future.
click_button TODO mb_left TODO TODO (not yet settable in .yui files)
popup popup element - no Setting 'popup' turns the button into a 'popup button', where clicking the button will open or close a popup element, positioned relative to the button. This overrides the normal on_click behavior. See the example above.

Positioning/Visuals

Property Type Default Value? Bindable? Description
padding number or {padding definition} 0 no padding allows you to define a 'buffer zone' around the text content. For example, setting padding to 5 will put 5 pixels worth of space around all sides of the content.
bg_sprite sprite asset name - no bg_sprite specifies a sprite to draw as the background of the child elements. Using a nine-sliced sprite is recommended.
bg_color GMS color name or RGB hex code prefixed by $ e.g. $FF0000 - no Rather than setting bg_sprite, you can also set bg_color, which will simply draw a rectangle of the appropriate color as the background for the child elements.
border_color GMS color name or RGB hex code prefixed by $ e.g. $FF0000 - no When not using bg_sprite you can also set border_color to draw an (unfilled) rectangle around the child elements in the specified color.
border_thickness real number 1 no Used in conjunction with bg_color, border_thickness defines the thickness of the border rectangle.