Environment: Windows 10 Pro 64bit, Chrome, Godot 3.0.2, GDScript
Goal is to capture the mouse on left clicking the Player node, then keep it captured as long as the left button is released.
Relevant code in the Player's script:
func _on_Player_input_event( viewport, event, shape_idx ):
if event.is_action_pressed("player_select"):
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(event):
if event.is_action_released("player_select"):
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
The player_select action is bound to the left mouse button in the project settings.
It works perfectly if run from the editor or exported as a Windows Desktop application (EXE).
The HTML5 exported version yields an error on left clicking the player:
**ERROR**: MOUSE_MODE_CAPTURED can only be entered from within an appropriate input callback
**ERROR**: At: platform/javascript/os_javascript.cpp:596:set_mouse_mode() - Condition ' result == -2 ' is true.
What is the appropriate input callback to use in this case?
Thank you.