From 3366122e1aecf46c668e47d8c40041b53d247dc0 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Wed, 10 Feb 2021 16:22:48 +0100 Subject: [HTML5] Handle contextmenu, webglcontextlost internally. This way they are automatically cleaned up when the engine exits, landing a hand to browsers garbage collectors. --- platform/javascript/js/libs/library_godot_display.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'platform/javascript/js/libs') 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 */ -- cgit v1.2.3