User Tools

Site Tools


built_in:alert

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
built_in:alert [2018/05/20 19:55]
geez437
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 5: Line 5:
  
 <code> app.Alert( text, title, options, hue );</code> <code> app.Alert( text, title, options, hue );</code>
-options can be "NoDim". The argument [[built_in:hue|hue]] represents the color of the title text and the horizontal line below.  
  
 ---- ----
 +=====Options=====
 +^ Option   ^ Description                     ^
 +| "NoDim"  | Set the background transparent  |
 +=====Examples=====
  
-====Examples==== +====No Title====
- +
-===No Title===+
  
 <code javascript> <code javascript>
Line 23: Line 24:
  
  
-===Title===+====Custom Title====
  
 <code javascript> <code javascript>
Line 34: Line 35:
 </code> </code>
  
-===Hue===+====Custom Hue===
 + 
 +The argument [[built_in:hue|hue]] represents the color of the title text and the horizontal line below. 
  
 <code javascript> <code javascript>
Line 48: Line 51:
 {{ https://i.imgur.com/TUgy5Cd.jpg }} {{ https://i.imgur.com/TUgy5Cd.jpg }}
  
 +======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 )
 +{
 +    //background-layout
 +    htmlAlertLayout = app.CreateLayout( "linear", "VCenter,FillXY" );
 +    htmlAlertLayout.Animate( "FadeIn", "", 100 );
 +    htmlAlertLayout.SetBackColor( [bclr.slice(0, 1), "33", bclr.slice(1)].join('') );
 +    
 +    //alert-layout
 +    htmlAlert = app.CreateLayout( "linear", "Left" );
 +    htmlAlert.SetBackColor( bclr );
 +    htmlAlert.SetSize( 0.8, 0.2 );
 +    
 +    //title-text
 +    htmlAlertTitle = app.CreateText( title );
 +    htmlAlertTitle.SetTextSize( 30 );
 +    htmlAlertTitle.SetMargins( 0.02 );
 +    htmlAlertTitle.SetTextColor( clr2 );
 +    
 +    //horizontal line below
 +    htmlAlertHr = app.CreateText( "", 1, 0.002 );
 +    htmlAlertHr.SetBackColor( clr2 );
 +    
 +    //text in alert
 +    htmlAlertText = app.CreateText( "", 0.8, 100, "Multiline,Left");
 +    htmlAlertText.SetMargins( 0.02 );
 +    htmlAlertText.SetHtml( text );
 +    htmlAlertText.SetTextColor( clr1 );
 +    
 +    //horizontal line below
 +    htmlAlertHr2 = app.CreateText( "", 0.8, 0.002 );
 +    htmlAlertHr2.SetBackColor( clr2 );
 +    
 +    //"Ok" button
 +    htmlAlertButton = app.CreateText( "Ok", 0.8, 0.055 );
 +    htmlAlertButton.SetPadding( 0, 0.01 );
 +    htmlAlertButton.SetBackColor( bclr );
 +    htmlAlertButton.SetTextColor( clr1 );
 +    htmlAlertButton.SetOnTouchUp( function() { htmlAlertLayout.Animate( "FadeOut", "", 100 ); app.RemoveLayout( htmlAlertLayout ); } );
 +    
 +    //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);
 +}
 +</code>
  
 +and call the method for example like that
 +
 +<code javascript>
 +//Called when application is started.
 +function OnStart()
 +{
 +    app.EnableBackKey( false );
 +    lay = app.CreateLayout( "linear" );
 +    lay.SetSize( 1, 1 );
 +    lay.SetBackColor( "#fff56f" );
 +    app.AddLayout( lay );
 +}
 +
 +function OnBack()
 +{
 +    HtmlAlert( "<s>text</s><br><b>text</b><br><u>text</u>", "#fff56f", "title", "#fff56f", "#121212" );    
 +}
 +</code>
  
 +Then you are able to use HTML tags in an alert.
  
 +{{ https://i.imgur.com/U7oeTsO.jpg }}
  
  
built_in/alert.1526846101.txt.gz · Last modified: 2018/05/21 03:55 (external edit)