Back

CreateMenuWithIcon

Hello World
Content:
- Methods

Advance MUI implementation of material design menu with additional icon using material icon font.

mwi = MUI.CreateMenuWithIcon( list, width, height, position ) → Object

Example - Basic

cfg.Light
cfg.MUI

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

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

        btn = MUI.CreateButtonRaised("SHOW MENU", 0.35)
        btn.SetOnTouch(ShowMenu)
        lay.AddChild(btn)

    app.AddLayout(lay)

    var list = ["Settings:settings", "Location:location_on", "Camera:camera", "Account:person"]
    lst = MUI.CreateMenuWithIcon(list, null, null, "Top, Right")
    lst.SetOnSelect(OnSelect)
}

function ShowMenu()
{
    lst.Show()
}

function OnSelect(choice)
{
    app.ShowPopup(choice)
}
Copy All       Run      

Example - Dark & Bottom,Right

cfg.Light
cfg.MUI

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

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

        btn = MUI.CreateButtonRaised("SHOW MENU", 0.35)
        btn.SetOnTouch(ShowMenu)
        lay.AddChild(btn)

    app.AddLayout(lay)

    var list = ["Settings:settings", "Location:location_on", "Camera:camera", "Account:person"]
    lst = MUI.CreateMenuWithIcon(list, null, null, "Bottom, Right")
    lst.SetOnSelect(OnSelect)
}

function ShowMenu()
{
    lst.Show()
}

function OnSelect(choice, index)
{
    app.ShowPopup(choice+" : "+index)
}
Copy All       Run      

Methods

The following methods are available on the MenuWithIcon object:

Focus()
GetAbsHeight() → Number: integer
GetAbsWidth() → Number: integer
GetHeight( options ) → Number
GetLeft( options ) → Number
GetParent() → app object
GetPosition( options ) → Object: { left, top, right, bottom }
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)
String: “Top”, “Left” or “Top”, “Right” or “Bottom”, “Left” or “Bottom”, “Right”
String: “px”
String: “screen”, “px”
String: “Show” or “Hide” or “Gone”
List: str
function( text, index )
mwi.ClearFocus
Removes the focus of the control so that the user no longer has immediate access to it.
mwi.Focus
Set the focus to the control so that the user can interact with it immediately.
mwi.GetAbsHeight
Get the absolute height of the control in pixels.
mwi.GetAbsWidth
Get the absolute width of the control in pixels.
mwi.GetHeight
Get the height of the control as screen height relative float or in pixels with the px option.
mwi.GetLeft
Get the distance from the control to the left parent border as width relative float or in pixels with the px option.
mwi.GetParent
Returns the parent control object where the object was added to - commonly a layout.
mwi.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.
mwi.GetTop
Get the distance from the control to the upper parent border as height relative float or in pixels with the px option.
mwi.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
mwi.GetWidth
Get the width of the control as screen width relative float or in pixels with the px option.
mwi.Gone
Hides the control without consuming any more layout space as if it were never there.
mwi.Hide
Hide the control but keep the layout space free.
mwi.IsEnabled
Returns whether the control is currently useable by the user.
mwi.IsOverlap
Returns whether the control overlaps with another by a given distance.
mwi.IsVisible
Returns whether the control is currently visible to the user, ignoring overlaying controls.
mwi.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.
mwi.SetOnSelect
Calls a function when item is click
mwi.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
mwi.Show
Set the visibility of the control to “Show”.