Component:ButtonToggle: Difference between revisions

From Resonite Wiki
imported>Psychpsyo
Wrote article.
 
This is no longer a stub. Style. Updated descriptions, added links.
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
<translate>
<translate>
<!--T:1-->
<!--T:1-->
{{stub}}
{{Infobox Component
{{Infobox Component
|Image=ButtonToggleComponent.png
|Image=ButtonToggleComponent.png
Line 8: Line 7:
}}
}}


The ButtonValueToggle component can be used to make a button that switches a boolean value between true and false every time the button is pressed.
The '''ButtonValueToggle''' component can be used to make an [[Type:IButton|IButton]] that switches a [[Type:bool|boolean]] value between <code>true</code> and <code>false</code> every time the button is pressed.


<!--T:2-->
<!--T:2-->
== Fields ==
== Fields ==
{{Table ComponentFields
{{Table ComponentFields
|TargetValue|IField`1|TypeString0=IField<bool>| The boolean to invert whenever the button is pressed.
|TargetValue|'''[[Type:IField`1|IField`1]]&lt;[[Type:Bool|Bool]]&gt;'''|TypeAdv0=true| The [[Type:bool|boolean]] to invert whenever the button is pressed.
}}
}}


<!--T:3-->
<!--T:3-->
== Usage ==
== Usage ==
To function, the component simply needs to be attached to a slot that also has a button component attached to it. From then on, pressing that button will activate the ButtonToggle, making it toggle its <code>TargetValue</code> from true to false or the other way round.
To function, the component simply needs to be attached to a [[Slot|slot]] that also has a button component attached to it. From then on, pressing that button will activate the '''ButtonToggle''', making it toggle its <code>TargetValue</code> from true to false or the other way round.


<!--T:4-->
<!--T:4-->
Line 26: Line 25:
== Related Components ==
== Related Components ==
</translate>
</translate>
[[Category:ComponentStubs]]
[[Category:Components{{#translation:}}|Button Toggle]]
[[Category:Components{{#translation:}}|Button Toggle]]
[[Category:Components:Common UI:Button Interactions{{#translation:}}|Button Toggle]]
[[Category:Components:Common UI:Button Interactions{{#translation:}}|Button Toggle]]

Latest revision as of 00:07, 12 September 2024

Component image 
Button Toggle component as seen in the Scene Inspector


The ButtonValueToggle component can be used to make an IButton that switches a boolean value between true and false every time the button is pressed.

Fields

Fields
Name Type Description
persistent Bool Determines whether or not this item will be saved to the server.
UpdateOrder Int Controls the order in which this component is updated.
Enabled Bool Controls whether or not this component is enabled.
TargetValue IField`1<Bool> The boolean to invert whenever the button is pressed.

Usage

To function, the component simply needs to be attached to a slot that also has a button component attached to it. From then on, pressing that button will activate the ButtonToggle, making it toggle its TargetValue from true to false or the other way round.

Examples

Related Components