CT WEBBROWSER: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Remove RV template usage)
 
Line 26: Line 26:


=== ctrlWebBrowserAction ===
=== ctrlWebBrowserAction ===
<pre>
{{RV|type=command
{{RV|type=command


Line 73: Line 75:
|seealso= [[ctrlURL]] [[menuSetURL]]
|seealso= [[ctrlURL]] [[menuSetURL]]
}}
}}
</pre>


=== Control EventHandler ===


=== Control EventHandler ===
This eventhandler can only be added to WebBrowser controls
This eventhandler can only be added to WebBrowser controls



Latest revision as of 11:03, 13 September 2024

Introduction

This is a experimental feature currently available for testing on Development-Branch. It is not yet decided whether this will become available in Stable branch. Please provide Feedback on the Arma Discord's #dev_rc_branch channel.

WebBrowser control features an embedded Chromium window.
The URL is subject to allowedHTMLLoadURIs[] whitelisting in CfgCommands config.
ctrlSetURL Can be used to change the URL after creation of the control.


Related commands & functions

Related User Interface Eventhandlers

Alphabetical Order

TokenNames common to most controls, such as x, y, w, h, text, idc... can be found here.
Not all of the listed attributes might have an effect nor might the list be complete. All attributes were gathered with this config crawler.
#define CT_WEBBROWSER 106



U

url

Type
String
Description
URL to be opened
url = "https://arma3.com";



Scripting

ctrlWebBrowserAction

{{RV|type=command

|game1= arma3dev
|version1= 2.20

|gr1= GUI Control

|descr= Executes an action on a WebBrowser control. The type of parameters depends on the action type. Possible Actions are:
{{{!}} class="wikitable"
{{!}}-
! Action
! Parameter
! Result
! Description
{{!}}-
{{!}} OpenDevConsole
{{!}} None
{{!}} [[Nothing]]
{{!}} Opens a Chrome Developer console for this browser, in a external window.
{{!}}-
{{!}} ExecJS
{{!}} [[String]]
{{!}} [[Nothing]]
{{!}} Executes Javascript code inside the currently loaded page.
{{!}}-
{{!}} JSResponse
{{!}} [[Boolean]]
{{!}} [[Nothing]]
{{!}} Respond to a Javascript alert() or confirm(), after triggered by "JSDialog" Eventhandler
{{!}}-
{{!}} OpenDataAsURL
{{!}} [[String]]
{{!}} [[Nothing]]
{{!}} Displays provided data in browser. This can be used to load HTML from a file and display it in the Browser window.
{{!}}}

|s1= control [[ctrlWebBrowserAction]] [Action, ...]

|p1= control: [[Control]]
|p2= Action: [[String]]

|r1= [[Nothing]]

|x1= <sqf>_control ctrlWebBrowserAction ["OpenDataAsURL", loadFile "example.html"];</sqf>

|seealso= [[ctrlURL]] [[menuSetURL]]
}}

Control EventHandler

This eventhandler can only be added to WebBrowser controls


JSDialog

  • Use on: Control (CT_WEBBROWSER)
  • Fired on: Fires when Javascript triggers a alert() or confirm() dialog.
  • Returns: Display or control, for controls it also returns the control's config (since Arma 3 logo black.png1.56).

params ["_control", "_isConfirmDialog", "_message"];
The code handling this event can return a Boolean true/false. Which will stop the next Eventhandlers from being triggered, and will be interpreted as a reply to the dialog.
If the code does not immediately provide a reply, it should return Nothing.
If the code does not return bool, then the script must call ctrlWebBrowserAction with the "JSDialog" action to reply to the dialog, the WebBrowser will be unresponsive until a reply has been sent.


Default Classes

Arma 3
AddOns: Classes need to be initialised first with class SomeClass;

Missions: Since Arma 3 v2.02 one can use import SomeClass; to initialise a class (see the import keyword).

In older versions, use "Default" call BIS_fnc_exportGUIBaseClasses; and paste the result into the description.ext.


RscWebBrowser

Baseline RscExtension example

class RscExtension
{
	type = CT_WEBBROWSER; // 106
	idc = -1;
	deletable = 0;
	style = 0;
	x = 0;
	y = 0;
	w = 0.3;
	h = 0.3;
	url= "https://arma3.com";
};