Back

CreateDialog

Hello World
Content:
- Methods

Creates a customizable materialize dialog.

dlg = MUI.CreateDialog( title, body, okText, cancelText, divider ) → Object

Example - Basic & Light

cfg.Light
cfg.MUI

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

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

        btn = MUI.CreateButtonRaised("SHOW DIALOG", 0.5)
        btn.SetOnTouch(ShowDialog)
        lay.AddChild(btn)

    app.AddLayout(lay)

    var text = "You can undone this process."
    dlg = MUI.CreateDialog("Remove message", text, "REMOVE")
}

function ShowDialog()
{
    dlg.Show()
}
Copy All       Run      

Example - Customize & Dark

cfg.Dark
cfg.MUI

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

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

        btn = MUI.CreateButtonRaised("SHOW DIALOG", 0.5)
        btn.SetOnTouch(ShowDialog)
        lay.AddChild(btn)

    app.AddLayout(lay)

    var text = "You can undone this process."
    dlg = MUI.CreateDialog("Remove message", text, "REMOVE", "CLOSE", true)
    dlg.SetOnTouch(OnTouch)
}

function ShowDialog()
{
    dlg.Show()
}

function OnTouch(val, btnTxt)
{
    if(val && btnTxt == "REMOVE")
        app.ShowPopup("Confirmed. Proceed an action")
    else
        app.ShowPopup("You decline the confirmation.")
}
Copy All       Run      

Methods

The following methods are available on the Dialog 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: Show divider or hide
Boolean
app object
Number
String
Number: fraction (0..1)
String:
  hexadecimal: “#rrggbb”, “#aarrggbb”
  colourName: “red”, “green”, ...
String: html code
String: “Title”
String: “Body text”
String: “Truthy button text”
String: “Falsey button text”
String: “px”
String: “screen”, “px”
String: “px” or “dip” or “sp” or “mm” or “pt” or pl or ps
String: “New title text”
String: “Show” or “Hide” or “Gone”
function()
function( isOkBtnClick, btnText )
dlg.ClearFocus
Removes the focus of the control so that the user no longer has immediate access to it.
dlg.Focus
Set the focus to the control so that the user can interact with it immediately.
dlg.GetAbsHeight
Get the absolute height of the control in pixels.
dlg.GetAbsWidth
Get the absolute width of the control in pixels.
dlg.GetHeight
Get the height of the control as screen height relative float or in pixels with the px option.
dlg.GetLeft
Get the distance from the control to the left parent border as width relative float or in pixels with the px option.
dlg.GetParent
Returns the parent control object where the object was added to - commonly a layout.
dlg.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.
dlg.GetTop
Get the distance from the control to the upper parent border as height relative float or in pixels with the px option.
dlg.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
dlg.GetWidth
Get the width of the control as screen width relative float or in pixels with the px option.
dlg.Gone
Hides the control without consuming any more layout space as if it were never there.
dlg.Hide
Hide the control but keep the layout space free.
dlg.IsEnabled
Returns whether the control is currently useable by the user.
dlg.IsOverlap
Returns whether the control overlaps with another by a given distance.
dlg.IsVisible
Returns whether the control is currently visible to the user, ignoring overlaying controls.
dlg.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.
dlg.SetHtml
Change the current text of the control to html-formatted text.
dlg.SetOnClose
Define a callback to be called when the dialog of control is closed.
dlg.SetOnTouch
Calls a function when buttons are click (prev. SetOnTouchOK)
dlg.SetText
Change the currently displayed text in the control.
dlg.SetTextColor
Change the text color of the contained text.
dlg.SetTextSize
Change the size of the contained text.
dlg.SetTitle
Sets a new title text
dlg.SetTitleColor
Change the color of the title text
dlg.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
dlg.Show
Set the visibility of the control to “Show”.