Documentation

Want to improve the docs? Take a look at scripting-api-data!
Found a bug? jc3mp/bugs is a good place to let us know.

WebUIWindow

Constructible This class can be instantiated from your script. You can find more information on the Constructor below. Auto Destroy To delete an instance of this class, use the `Destroy` function of this class. You can find the function definition below. Custom Properties You cannot add your own properties to instances of this class. They will not be saved and can cause undefined behavior.

Constructor

new WebUIWindow(string name, string location, Vector2 size)

  • name: the internal name of the CEF UI window
  • location: the location of the page which CEF should load
  • size: the size of the CEF UI window

Example

var webuiwindow = new WebUIWindow('myui', 'package://my_package/index.html', new Vector2(jcmp.viewportSize.x, jcmp.viewportSize.y));

Properties

Name Type Description
size Vector2 the size of the CEF UI window
location string the location of the page which CEF should load
hidden boolean whether the UI should be hidden or not
position Vector2 the WebUIWindow's position in the game world
autoResize boolean whether the CEF UI should resize itself when the game resolution is changed or not
captureMouseInput boolean whether mouse input should be captured by the CEF UI or not
texture Texture read only the CEF UI texture
autoRenderTexture boolean whether the texture is automatically drawn by the renderer or not

Functions

WebUIWindow.BringToFront()

Brings the CEF UI to the front

Example

function createMyUI() {
  var firstUI = new WebUIWindow("myFirstUI", "package://my_client_package/index1.html", new Vector2(jcmp.viewportSize.x, jcmp.viewportSize.y));
  var secondUI = new WebUIWindow("mySecondUI", "package://my_client_package/index2.html", new Vector2(jcmp.viewportSize.x, jcmp.viewportSize.y));

  //Brings "myFirstUI" to the front so it is visible
  //Without this, we would see the second created UI on top and not the first one
  firstUI.BringToFront();
}
createMyUI();           

WebUIWindow.Reload(boolean ignoreCache)

Reload a certain CEF UI

Parameter

Name Type Description
ignoreCache boolean whether the cache should be ignored

Example

function createMyUI() {
  var myUI = new WebUIWindow("myUI", "package://my_client_package/index1.html", new Vector2(jcmp.viewportSize.x, jcmp.viewportSize.y));

  //Change the location property and force the UI to reload
  myUI.location = "package://my_client_package/index2.html";
  myUI.Reload(true);
}
createMyUI();

WebUIWindow.CallEvent(string name, any ...args)

Calls an Event on the UI that has been added using jcmp.AddEvent

returns: undefined

Parameter

Name Type Description
name string event name
...args any optional event arguments

WebUIWindow.AddEvent(string name, function handler)

Adds an Event Handler so the UI can call it using jcmp.CallLocalEvent

returns: undefined

Parameter

Name Type Description
name string event name
handler function handler function

WebUIWindow.Destroy()

Destroys the WebUIWindow

Stay informed

By becoming the newest member of our growing forums, we and hundreds of other players will always keep you up to date on everything JC3:MP related.