0 votes

Hi there...

I'm trying to implement a FullScreen toggle in my Godot 3.0 game, which is working perfectly well on Linux- and Windows exports...

Looks like this...

    if Input.is_action_just_released("ui_toggleFullscreen"):
        OS.window_fullscreen = !OS.window_fullscreen
        get_node("NEDB-PD-SUBCaptions").add_infoMessage("Toggle FullScreen " + ("on" if OS.window_fullscreen else "off"))

In my Linux / Windows export it expectedly states "Toggle Fullscreen on" / "Toggle FullScreen off" respectively...

However in the HTML5 export it doesn't...

No matter how often I trigger ui_toggleFullscreen it always responds "*Toggle FullScreen off*"

I'm trying to understand this (https://docs.godotengine.org/en/3.0/getting_started/workflow/export/exporting_for_web.html#full-screen-and-mouse-capture) description I found while RTFM but obviously I'm not smart enough to get the concept... : - / ...

Could anybody try to make me understand...please...???

THX and cheers...

asked Nov 13, 2018 in Engine by Zappo_II (26 points)

Do you have your code inside of a input or _unhandledinput function?
Or could you paste the whole funciton the you use and where you call it or trough what action in the UI?

Code Snippet of above is in _process(delta) where I handle all my inputs for global game mode stuff like that...
No code in neither input() nor _unhandledinput() ...
Its less a technical coding questen but more a general concept question since I am unable to understand what the DOCs try to tell me with this one:

Instead, these actions have to occur as a response to a JavaScript input event. In Godot, this is most easily done by entering full screen from within an input callback such as input or _unhandledinput.

What I'd like to achive is, pressing a specific Key in the Game context (aka GODOT Engine Game Code) lets the Browser switch to FullScreen...

I have some Ideas of how to do that in (non GODOT Engine Game Code) JavaScript surrounding the HTML5 index template but I don't think thats the way it's ment to be...

Perhaps you could add a clickable button to toggle fullscreen instead — I'm not sure if all browsers allow keys to enter fullscreen mode.

1 Answer

+1 vote
Best answer

You have to set OS.window_fullscreen from an _input() or _unhandled_input() callback function. _gui_input() also works for Control nodes. The event must not be an echo event. Mouse motion and screen drag events will probably not work either.

Documentation for input events is here: https://docs.godotengine.org/en/3.0/tutorials/inputs/inputevent.html

For example:

func _input(ev):
    if ev.is_action_pressed('ui_toggleFullscreen'):
        OS.window_fullscreen = !OS.window_fullscreen
answered Nov 19, 2018 by eska (1,022 points)
selected Nov 24, 2018 by Zappo_II

THANXALOT, works as expected after moving to _input ...
Cheers...

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.