Back

CreateSpinner

Hello World
Content:
- Methods

Creates a material designed dropdown.

spn = MUI.CreateSpinner( list, width, height ) → app object

Let the user select from a predefined options.

Example - Basic

cfg.Light
cfg.MUI

function OnStart()
{
    color = MUI.colors.teal
    app.InitializeUIKit(color.teal)

    lay = MUI.CreateLayout("Linear", "FillXY,VCenter")

        spn = MUI.CreateSpinner("Item 1, Item 2, Item 3", 0.6, 0.1)
        spn.SetOnChange(OnChange)
        lay.AddChild(spn)

    app.AddLayout(lay)
}

function OnChange(value, index)
{
    app.ShowPopup(value)
}
Copy All       Run      

Methods

The following methods are available on the Spinner object:

GetAbsHeight() → Number: integer
GetAbsWidth() → Number: integer
GetHeight( options ) → Number
GetLeft( options ) → Number
GetParent() → app object
GetPosition( options ) → Object: { left, top, right, bottom }
GetText() → String
GetTop( options ) → Number
GetVisibility() → String: “Show” or “Hide” or “Gone”
GetWidth( options ) → Number
Gone()
Hide()
IsEnabled() → Boolean
IsOverlap( obj, depth ) → Boolean
IsVisible() → Boolean
Show()
Boolean
app object
Number
Number: fraction (0..1)
Number: integer
Number: milliseconds
Number: integer: The index of the option in the given values
String:
  hexadecimal: “#rrggbb”, “#aarrggbb”
  colourName: “red”, “green”, ...
String: “px”
String: “screen”, “px”
String: “Must be one of the provided values”
String: “The hint text.”
String: “px” or “sp” or “dip” or “mm” or “pt”
String: “px” or “dip” or “sp” or “mm” or “pt” or pl or ps
String: “Show” or “Hide” or “Gone”
String: “Linear.None” or “Quadratic.In/Out” or “Cubic.In/Out” or “Quartic.In/Out” or “Quintic.In/Out” or “Sinusoidal.In/Out” or “Exponential.In/Out” or “Circular.In/Out” or “Elastic.In/Out” or “Back.In/Out” or “Bounce.In/Out”
Object: { x, y, w, w, sw, sh, rot }
List: String. A comma separated options
List: A comma separated values for options.
function( value, index )
function()
spn.GetAbsHeight
Get the absolute height of the control in pixels.
spn.GetAbsWidth
Get the absolute width of the control in pixels.
spn.GetHeight
Get the height of the control as screen height relative float or in pixels with the px option.
spn.GetLeft
Get the distance from the control to the left parent border as width relative float or in pixels with the px option.
spn.GetParent
Returns the parent control object where the object was added to - commonly a layout.
spn.GetPosition
Returns data about the position and size of the control.
If the screen option is given the position on the screen will be returned. Otherwise relative to the parent control.
The px options turns the relative values into pixels.
spn.GetText
Returns the current displayed text of the control.
spn.GetTop
Get the distance from the control to the upper parent border as height relative float or in pixels with the px option.
spn.GetVisibility
Returns the current visibility state of the control. The Values are:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
spn.GetWidth
Get the width of the control as screen width relative float or in pixels with the px option.
spn.Gone
Hides the control without consuming any more layout space as if it were never there.
spn.Hide
Hide the control but keep the layout space free.
spn.IsEnabled
Returns whether the control is currently useable by the user.
spn.IsOverlap
Returns whether the control overlaps with another by a given distance.
spn.IsVisible
Returns whether the control is currently visible to the user, ignoring overlaying controls.
spn.SelectItem
Select an option
spn.SelectItemByIndex
Select an option with a given index.
spn.SetEnabled
En/Disable the control physically and visually so that the user can/can not access the control. Events like OnTouch will still be fired.
spn.SetHint
Sets the hint when there is no active selection.
spn.SetList
Sets a new list of options.
spn.SetMargins
Define a distance to other controls on each side of the control.
spn.SetOnChange
Calls a function when value changes
spn.SetPosition
Defines the position and size for the control if the parent is an absolute layout.
spn.SetTextColor
Change the text color of the contained text.
spn.SetTextSize
Change the size of the contained text.
spn.SetVisibility
Change the visibility of the control to one of the available modes:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
spn.Show
Set the visibility of the control to “Show”.
spn.Tween
Performs an animation on the control.
The target object is for the position, size and rotation that the control has at the end of the animation.

The type specifies the behavior and the speed of the animation. Separated by a dot, you must also specify whether you want to apply this behavior to the beginning (In), end (Out), or to both (InOut) times of the animation.

With the amount of repeats you can control how many times you want to play the animation.

If you have jojo activated, the animation will alternate between forward and backward playback, so that if the repetition value is odd, the control will be at the start position again at the end of the animation.

Finally the callback function will be called after the animation has finished. Well, it's about time!