BrowserCreated: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
Line 16: Line 16:


<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
using System;
    public Main()
    {
        // Subscribe to event
        RAGE.Events.OnBrowserCreated += Main.OnBrowserCreated;


namespace Demo
        // Create CEF Browser
{
        RAGE.Ui.HtmlWindow htmlWindow = new RAGE.Ui.HtmlWindow("package://index.html");
     public class Main : RAGE.Events.Script
    }
     public static void OnBrowserCreated(RAGE.Ui.HtmlWindow htmlWindow)
     {
     {
         public Main()
         htmlWindow.Active = false;
        {
            // Subscribe to event
            RAGE.Events.OnBrowserCreated += Main.OnBrowserCreated;
 
            // Create CEF Browser
            RAGE.Ui.HtmlWindow htmlWindow = new RAGE.Ui.HtmlWindow("package://index.html");
        }
 
        public static void OnBrowserCreated(RAGE.Ui.HtmlWindow htmlWindow)
        {
            htmlWindow.Active = false;


            RAGE.Chat.Output("A CEF Browser has been created and is now invisable!");
        RAGE.Chat.Output("A CEF Browser has been created and is now invisable!");
        }
     }
     }
}
</syntaxhighlight>
</syntaxhighlight>



Revision as of 22:24, 26 November 2018

Client-Side

This event is called everytime a browser is created.

C# Syntax

C#

{{{1}}}

public void OnBrowserCreated(window){}

Parameters

  • window: The created browser handler, output expects RAGE.Ui.HtmlWindow type.

Examples

The example below shows up a message for a player and hides the browser when it is created.

    public Main()
    {
        // Subscribe to event
        RAGE.Events.OnBrowserCreated += Main.OnBrowserCreated;

        // Create CEF Browser
        RAGE.Ui.HtmlWindow htmlWindow = new RAGE.Ui.HtmlWindow("package://index.html");
    }
    public static void OnBrowserCreated(RAGE.Ui.HtmlWindow htmlWindow)
    {
        htmlWindow.Active = false;

        RAGE.Chat.Output("A CEF Browser has been created and is now invisable!");
    }

JavaScript Syntax

JavaScript
mp.events.add('browserCreated', (browser) => {});

Parameters

  • browser: The created browser handler, output expects any type.

Examples

The example below shows up a message for a player when a browser is created.

mp.events.add('browserCreated', (browser) => {
    mp.gui.chat.push('WOOOOOOAH, a CEF Browser has been created!');
});