[HTML5] Add option to focus canvas on start.
Enabled by default.
This commit is contained in:
parent
c8444c3ee0
commit
c12fca57f4
3 changed files with 15 additions and 0 deletions
|
@ -450,6 +450,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
|
||||||
}
|
}
|
||||||
config["canvasResizePolicy"] = p_preset->get("html/canvas_resize_policy");
|
config["canvasResizePolicy"] = p_preset->get("html/canvas_resize_policy");
|
||||||
config["experimentalVK"] = p_preset->get("html/experimental_virtual_keyboard");
|
config["experimentalVK"] = p_preset->get("html/experimental_virtual_keyboard");
|
||||||
|
config["focusCanvas"] = p_preset->get("html/focus_canvas_on_start");
|
||||||
config["gdnativeLibs"] = libs;
|
config["gdnativeLibs"] = libs;
|
||||||
config["executable"] = p_name;
|
config["executable"] = p_name;
|
||||||
config["args"] = args;
|
config["args"] = args;
|
||||||
|
@ -650,6 +651,7 @@ void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_op
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "*.html"), ""));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "*.html"), ""));
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/head_include", PROPERTY_HINT_MULTILINE_TEXT), ""));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/head_include", PROPERTY_HINT_MULTILINE_TEXT), ""));
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "html/canvas_resize_policy", PROPERTY_HINT_ENUM, "None,Project,Adaptive"), 2));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "html/canvas_resize_policy", PROPERTY_HINT_ENUM, "None,Project,Adaptive"), 2));
|
||||||
|
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "html/focus_canvas_on_start"), true));
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "html/experimental_virtual_keyboard"), false));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "html/experimental_virtual_keyboard"), false));
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "progressive_web_app/enabled"), false));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "progressive_web_app/enabled"), false));
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "progressive_web_app/offline_page", PROPERTY_HINT_FILE, "*.html"), ""));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "progressive_web_app/offline_page", PROPERTY_HINT_FILE, "*.html"), ""));
|
||||||
|
|
|
@ -90,6 +90,14 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
args: [],
|
args: [],
|
||||||
|
/**
|
||||||
|
* When enabled, the game canvas will automatically grab the focus when the engine starts.
|
||||||
|
*
|
||||||
|
* @memberof EngineConfig
|
||||||
|
* @type {boolean}
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
focusCanvas: true,
|
||||||
/**
|
/**
|
||||||
* When enabled, this will turn on experimental virtual keyboard support on mobile.
|
* When enabled, this will turn on experimental virtual keyboard support on mobile.
|
||||||
*
|
*
|
||||||
|
@ -238,6 +246,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
|
||||||
this.persistentPaths = parse('persistentPaths', this.persistentPaths);
|
this.persistentPaths = parse('persistentPaths', this.persistentPaths);
|
||||||
this.persistentDrops = parse('persistentDrops', this.persistentDrops);
|
this.persistentDrops = parse('persistentDrops', this.persistentDrops);
|
||||||
this.experimentalVK = parse('experimentalVK', this.experimentalVK);
|
this.experimentalVK = parse('experimentalVK', this.experimentalVK);
|
||||||
|
this.focusCanvas = parse('focusCanvas', this.focusCanvas);
|
||||||
this.gdnativeLibs = parse('gdnativeLibs', this.gdnativeLibs);
|
this.gdnativeLibs = parse('gdnativeLibs', this.gdnativeLibs);
|
||||||
this.fileSizes = parse('fileSizes', this.fileSizes);
|
this.fileSizes = parse('fileSizes', this.fileSizes);
|
||||||
this.args = parse('args', this.args);
|
this.args = parse('args', this.args);
|
||||||
|
@ -324,6 +333,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
|
||||||
'locale': locale,
|
'locale': locale,
|
||||||
'persistentDrops': this.persistentDrops,
|
'persistentDrops': this.persistentDrops,
|
||||||
'virtualKeyboard': this.experimentalVK,
|
'virtualKeyboard': this.experimentalVK,
|
||||||
|
'focusCanvas': this.focusCanvas,
|
||||||
'onExecute': this.onExecute,
|
'onExecute': this.onExecute,
|
||||||
'onExit': function (p_code) {
|
'onExit': function (p_code) {
|
||||||
cleanup(); // We always need to call the cleanup callback to free memory.
|
cleanup(); // We always need to call the cleanup callback to free memory.
|
||||||
|
|
|
@ -72,6 +72,9 @@ const GodotConfig = {
|
||||||
GodotConfig.persistent_drops = !!p_opts['persistentDrops'];
|
GodotConfig.persistent_drops = !!p_opts['persistentDrops'];
|
||||||
GodotConfig.on_execute = p_opts['onExecute'];
|
GodotConfig.on_execute = p_opts['onExecute'];
|
||||||
GodotConfig.on_exit = p_opts['onExit'];
|
GodotConfig.on_exit = p_opts['onExit'];
|
||||||
|
if (p_opts['focusCanvas']) {
|
||||||
|
GodotConfig.canvas.focus();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
locate_file: function (file) {
|
locate_file: function (file) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue