This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
built_in:alert [2018/05/20 19:58] geez437 [Examples] |
built_in:alert [2018/05/22 02:16] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | =====Alert===== | + | ======Alert====== |
The **Alert** method shows a popup message on the screen which stays on | The **Alert** method shows a popup message on the screen which stays on | ||
Line 7: | Line 7: | ||
---- | ---- | ||
- | ====Options==== | + | =====Options===== |
^ Option | ^ Option | ||
| " | | " | ||
+ | =====Examples===== | ||
- | ---- | + | ====No Title==== |
- | ====Examples==== | + | |
- | + | ||
- | ===No Title=== | + | |
<code javascript> | <code javascript> | ||
Line 26: | Line 24: | ||
- | ===Title=== | + | ====Custom |
<code javascript> | <code javascript> | ||
Line 37: | Line 35: | ||
</ | </ | ||
- | ===Hue=== | + | ====Custom |
The argument [[built_in: | The argument [[built_in: | ||
Line 53: | Line 51: | ||
{{ https:// | {{ 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 ) | ||
+ | { | ||
+ | // | ||
+ | htmlAlertLayout = app.CreateLayout( " | ||
+ | htmlAlertLayout.Animate( " | ||
+ | htmlAlertLayout.SetBackColor( [bclr.slice(0, | ||
+ | | ||
+ | // | ||
+ | htmlAlert = app.CreateLayout( " | ||
+ | htmlAlert.SetBackColor( bclr ); | ||
+ | htmlAlert.SetSize( 0.8, 0.2 ); | ||
+ | | ||
+ | // | ||
+ | htmlAlertTitle = app.CreateText( title ); | ||
+ | htmlAlertTitle.SetTextSize( 30 ); | ||
+ | htmlAlertTitle.SetMargins( 0.02 ); | ||
+ | htmlAlertTitle.SetTextColor( clr2 ); | ||
+ | | ||
+ | // | ||
+ | htmlAlertHr = app.CreateText( "", | ||
+ | htmlAlertHr.SetBackColor( clr2 ); | ||
+ | | ||
+ | //text in alert | ||
+ | htmlAlertText = app.CreateText( "", | ||
+ | htmlAlertText.SetMargins( 0.02 ); | ||
+ | htmlAlertText.SetHtml( text ); | ||
+ | htmlAlertText.SetTextColor( clr1 ); | ||
+ | | ||
+ | // | ||
+ | htmlAlertHr2 = app.CreateText( "", | ||
+ | htmlAlertHr2.SetBackColor( clr2 ); | ||
+ | | ||
+ | //" | ||
+ | htmlAlertButton = app.CreateText( " | ||
+ | htmlAlertButton.SetPadding( 0, 0.01 ); | ||
+ | htmlAlertButton.SetBackColor( bclr ); | ||
+ | htmlAlertButton.SetTextColor( clr1 ); | ||
+ | htmlAlertButton.SetOnTouchUp( function() { htmlAlertLayout.Animate( " | ||
+ | | ||
+ | //add objects to app | ||
+ | htmlAlert.AddChild( htmlAlertTitle ); | ||
+ | htmlAlert.AddChild( htmlAlertHr ); | ||
+ | htmlAlert.AddChild( htmlAlertText ); | ||
+ | htmlAlertLayout.AddChild( htmlAlert ); | ||
+ | htmlAlertLayout.AddChild( htmlAlertHr2 ); | ||
+ | htmlAlertLayout.AddChild( htmlAlertButton ); | ||
+ | app.AddLayout( htmlAlertLayout); | ||
+ | } | ||
+ | </ | ||
+ | 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:// | ||