BrowserCreated: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{ClientSide}}
{{ClientsideCsJsEvent}}
This event is called everytime a browser is created.
This event is called everytime a browser is created.


== C# Syntax ==
{{CSharpContainer|
{{CSharp}}
<syntaxhighlight lang="c#">
<syntaxhighlight lang="C#">
public delegate void OnBrowserCreatedDelegate(HtmlWindow window);
public void OnBrowserCreated(window){}
</syntaxhighlight>
</syntaxhighlight>


=== Parameters ===
{{Parameters}}
* '''window''': The created browser handler, output expects <span style="color: #408DAE"><b>RAGE.Ui.HtmlWindow</b></span> type.
* '''window''': The created browser handler, output expects '''RAGE.Ui.HtmlWindow''' type.
 
=== Examples ===


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


<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
    public Main()
RAGE.Events.OnBrowserCreated += OnBrowserCreated;
    {
</syntaxhighlight>
        // Subscribe to event
<syntaxhighlight lang="c#">
        RAGE.Events.OnBrowserCreated += Main.OnBrowserCreated;
public void OnBrowserCreated(RAGE.Ui.HtmlWindow htmlWindow)
{
    htmlWindow.Active = false;


        // Create CEF Browser
     RAGE.Chat.Output("A CEF Browser has been created and is now invisible!");
        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!");
    }
</syntaxhighlight>
</syntaxhighlight>
 
}}
== JavaScript Syntax ==
{{JSContainer|
{{JS}}
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
mp.events.add('browserCreated', (browser) => {});
mp.events.add('browserCreated', (browser) => {});
</syntaxhighlight>
</syntaxhighlight>


=== Parameters ===
{{Parameters}}
* '''browser''': The created browser handler, output expects <span style="color: #408DAE"><b>any</b></span> type.
* '''browser''': The created browser handler, output expects '''any''' type.
 
=== Examples ===


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


Line 50: Line 41:
});
});
</syntaxhighlight>
</syntaxhighlight>
}}
==See more==
{{Browser_definition_c}}
[[Category:Client-side Event]]

Latest revision as of 03:34, 28 May 2024

Client-Side Event

 C#  JavaScript


This event is called everytime a browser is created.


C# Syntax

public delegate void OnBrowserCreatedDelegate(HtmlWindow window);

Parameters

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

Example

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

RAGE.Events.OnBrowserCreated += OnBrowserCreated;
public void OnBrowserCreated(RAGE.Ui.HtmlWindow htmlWindow)
{
    htmlWindow.Active = false;

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


JavaScript Syntax

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

Parameters

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

Example

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!');
});


See more