diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-02-10 16:22:48 +0100 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-02-11 07:56:10 +0100 |
commit | 3366122e1aecf46c668e47d8c40041b53d247dc0 (patch) | |
tree | 54b9ed59bffc96bf32fe78f2ef522a008c630957 /platform/javascript/js/libs | |
parent | e9e2dedb7639d57cea9d4764efdf292a5154b86e (diff) |
[HTML5] Handle contextmenu, webglcontextlost internally.
This way they are automatically cleaned up when the engine exits,
landing a hand to browsers garbage collectors.
Diffstat (limited to 'platform/javascript/js/libs')
-rw-r--r-- | platform/javascript/js/libs/library_godot_display.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/platform/javascript/js/libs/library_godot_display.js b/platform/javascript/js/libs/library_godot_display.js index 2977b7c122..7b085aebc8 100644 --- a/platform/javascript/js/libs/library_godot_display.js +++ b/platform/javascript/js/libs/library_godot_display.js @@ -619,6 +619,18 @@ const GodotDisplay = { GodotDisplayListeners.add(canvas, 'drop', GodotDisplayDragDrop.handler(dropFiles)); }, + godot_js_display_setup_canvas__sig: 'v', + godot_js_display_setup_canvas: function () { + const canvas = GodotConfig.canvas; + GodotDisplayListeners.add(canvas, 'contextmenu', function (ev) { + ev.preventDefault(); + }, false); + GodotDisplayListeners.add(canvas, 'webglcontextlost', function (ev) { + alert('WebGL context lost, please reload the page'); // eslint-disable-line no-alert + ev.preventDefault(); + }, false); + }, + /* * Gamepads */ |