Skip to main content

Button

This view allows you to fire an event when the user taps it.

JSON Format

{
"type": "button",
"id": ...,
"type": ...,
"margin_left": ...,
"margin_right": ...,
"margin_top": ...,
"margin_bottom": ...,
"is_visible": ...,
"validation_message": ...,
"text": ...,
"enabled": ...,
"event_names": ...,
"event": ...
}

Fields

FieldTypeRequiredDescription
idStringA unique identifier for the view. You can use it to reference view values in stat formulas by doing $view.view_id (where view_id is the id that was assigned to this view by you in the system definition)
typeRPGViewTypeThe type of this view. Note that these are all in camelCase.
margin_leftdoubleOptional. How much margin to add to the left of this view.
margin_rightdoubleOptional. How much margin to add to the right of this view.
margin_topdoubleOptional. How much margin to add to the top of this view.
margin_bottomdoubleOptional. How much margin to add to the bottom of this view.
is_visibleStatFormulaComponentOptional. A formula to specify if the view should be visible or not. Must return a bool.
validation_messageStatFormulaComponentOptional. If this view is an input, you can define this formula to return a message when the input value is invalid. If the input is valid, you should return null. Otherwise, make the formula return the string that should be shown to the user.
textStatFormulaComponentA formula for the button's text. Must return a string.
enabledStatFormulaComponentOptional. Defaults to the true constant. A formula to signal if the button is enabled or not. A disabled button does nothing when pressed and will show greyed out.
event_namesStatFormulaComponentOptional. Either this property or event should be provided. A formula for the list of names (strings) of the events that should be fired. Each of these event names require you to make use of the eventName stat formula component where appropriate to ensure the events get picked up by the appropriate resource (for clarification, see the information banner in Mechanic).
eventEventOptional. Either this property or event_names should be provided. The event that should be fired when this button is pressed.