This shows you the differences between two versions of the page.
built_in:alert [2018/05/21 13:19] geez437 [HTML Alert] |
built_in:alert [2018/05/22 02:16] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Alert====== | ||
- | |||
- | The **Alert** method shows a popup message on the screen which stays on | ||
- | screen until the user presses the Ok button or back button. | ||
- | |||
- | < | ||
- | |||
- | ---- | ||
- | =====Options===== | ||
- | ^ Option | ||
- | | " | ||
- | =====Examples===== | ||
- | |||
- | ====No Title==== | ||
- | |||
- | <code javascript> | ||
- | |||
- | function OnStart() | ||
- | { | ||
- | app.Alert( "Hello World!" | ||
- | } | ||
- | |||
- | </ | ||
- | |||
- | |||
- | ====Custom Title==== | ||
- | |||
- | <code javascript> | ||
- | |||
- | function OnStart() | ||
- | { | ||
- | app.Alert( "Hello World!", | ||
- | } | ||
- | |||
- | </ | ||
- | |||
- | ====Custom Hue==== | ||
- | |||
- | The argument [[built_in: | ||
- | |||
- | <code javascript> | ||
- | |||
- | //Orange title and horizontal line | ||
- | function OnStart() | ||
- | { | ||
- | app.Alert( "Hello World!", | ||
- | } | ||
- | |||
- | </ | ||
- | |||
- | {{ https:// | ||
- | |||
- | ======HTML Alert====== | ||
- | |||
- | Normally it is not possible to use HTML tags in an alert. But if you add the following function to your script | ||
- | <code javascript> | ||
- | function HtmlAlert( text, clr1, title, clr2, bclr ) | ||
- | { | ||
- | // | ||
- | geez437 = app.CreateLayout( " | ||
- | geez437.Animate( " | ||
- | geez437.SetBackColor( [bclr.slice(0, | ||
- | | ||
- | // | ||
- | geez437Alert = app.CreateLayout( " | ||
- | geez437Alert.SetBackColor( bclr ); | ||
- | geez437Alert.SetSize( 0.8, 0.2 ); | ||
- | | ||
- | | ||
- | geez437Title = app.CreateText( title ); | ||
- | geez437Title.SetTextSize( 30 ); | ||
- | geez437Title.SetMargins( 0.02 ); | ||
- | geez437Title.SetTextColor( clr2 ); | ||
- | | ||
- | geez437Hr = app.CreateText( "", | ||
- | geez437Hr.SetBackColor( clr2 ); | ||
- | | ||
- | geez437Text = app.CreateText( "", | ||
- | geez437Text.SetMargins( 0.02 ); | ||
- | geez437Text.SetHtml( text ); | ||
- | geez437Text.SetTextColor( clr1 ); | ||
- | | ||
- | geez437Hr2 = app.CreateText( "", | ||
- | geez437Hr.SetBackColor( clr2 ); | ||
- | | ||
- | geez437Button = app.CreateText( " | ||
- | geez437Button.SetPadding( 0, 0.01 ); | ||
- | geez437Button.SetBackColor( bclr ); | ||
- | geez437Button.SetTextColor( clr1 ); | ||
- | geez437Button.SetOnTouchUp( function() { geez437.Animate( " | ||
- | | ||
- | | ||
- | //add objects to app | ||
- | geez437Alert.AddChild( geez437Title ); | ||
- | geez437Alert.AddChild( geez437Hr ); | ||
- | geez437Alert.AddChild( geez437Text ); | ||
- | geez437.AddChild( geez437Alert ); | ||
- | geez437.AddChild( geez437Hr2 ); | ||
- | geez437.AddChild( geez437Button ); | ||
- | app.AddLayout( geez437 ); | ||
- | } | ||
- | </ | ||
- | |||
- | and call the method for example like that | ||
- | |||
- | <code javascript> | ||
- | //Called when application is started. | ||
- | function OnStart() | ||
- | { | ||
- | app.EnableBackKey( false ); | ||
- | lay = app.CreateLayout( " | ||
- | lay.SetSize( 1, 1 ); | ||
- | lay.SetBackColor( "# | ||
- | app.AddLayout( lay ); | ||
- | } | ||
- | |||
- | function OnBack() | ||
- | { | ||
- | HtmlAlert( "< | ||
- | } | ||
- | </ | ||
- | |||
- | Then you are able to use HTML tags in an alert. | ||
- | |||
- | {{ https:// | ||
- | |||