Switch

Last Updated On 2021-07-16

Version 1MinSDK 7Tutorial Video

Toggle switch that raises an event when the user clicks on it. There are many properties affecting its appearance that can be set in the Designer or Blocks Editor.


Properties

You can set the below properties in the UI part of the builder.

  • BackgroundColor - it's a color value which is set to &h00ffffff by default.
  • CustomFontTypeFace - it's a asset value which is set to blank by default.
  • Enabled - it's a boolean value which is set to true by default.
  • FontBold - it's a boolean value which is set to false by default.
  • FontItalic - it's a boolean value which is set to false by default.
  • FontSize - it's a non negative float value which is set to 14.0 by default.
  • FontTypeface - it's a typeface value which is set to 0 by default.
  • HeihMargin - it's a four value which is set to 0,0,0,0 by default.
  • HeihPadding - it's a four value which is set to 0,0,0,0 by default.
  • MarginBottom - it's a non negative float value which is set to 0 by default.
  • MarginLeft - it's a non negative float value which is set to 0 by default.
  • MarginRight - it's a non negative float value which is set to 0 by default.
  • MarginTop - it's a non negative float value which is set to 0 by default.
  • On - it's a boolean value which is set to false by default.
  • PaddingBottom - it's a non negative float value which is set to 0 by default.
  • PaddingLeft - it's a non negative float value which is set to 0 by default.
  • PaddingRight - it's a non negative float value which is set to 0 by default.
  • PaddingTop - it's a non negative float value which is set to 0 by default.
  • Text - it's a string value which is set to blank by default.
  • TextColor - it's a color value which is set to &hff000000 by default.
  • ThumbColorActive - it's a color value which is set to &hffffffff by default.
  • ThumbColorInactive - it's a color value which is set to &hffcccccc by default.
  • TrackColorActive - it's a color value which is set to &hff00ff00 by default.
  • TrackColorInactive - it's a color value which is set to &hff444444 by default.
  • Visible - it's a visibility value which is set to true by default.

Block Properties

You can set the below blocks properties in the blocks section of the builder.

BackgroundColor

The background color of the Switch as an alpha-red-green-blue integer.


CustomFontTypeFace

Sets the custom font


Enabled

True if the Switch is active and clickable.


FontSize

Specifies the text font size of the Switch in scale-independent pixels.


Height

Specifies the vertical height of the Switch, measured in pixels.


HeightPercent

Specifies the vertical height of the Switch as a percentage of the height of the Screen.


MarginBottom

Property for MarginBottom


MarginLeft

Property for MarginLeft


MarginRight

Property for MarginRight


MarginTop

Property for MarginTop


On

Returns true if the `Switch` is on.


PaddingBottom

Property for PaddingBottom


PaddingLeft

Property for PaddingLeft


PaddingRight

Property for PaddingRight


PaddingTop

Property for PaddingTop


Text

Specifies the text displayed by the Switch.


TextColor

Specifies the text color of the Switch as an alpha-red-green-blue integer.


ThumbColorActive

Returns the `Switch`'s thumb color (button that toggles back and forth) when the switch is ON/Checked


ThumbColorInactive

Returns the `Switch`'s thumb color (button that toggles back and forth) when the switch is Off/Unchecked


TrackColorActive

Returns the `Switch`'s track color


TrackColorInactive

Color of the toggle track when switched off


Visible

Specifies whether the Switch should be visible on the screen. Value is true if the Switch is showing and false if hidden.


Width

Specifies the horizontal width of the Switch, measured in pixels.


WidthPercent

Specifies the horizontal width of the Switch as a percentage of the width of the Screen.



Events

You can set the below event blocks in the blocks section of the builder.

Changed

User change the state of the `Switch` from On to Off or back.

GotFocus

Switch became the focused component.

LostFocus

Switch stopped being the focused component.