This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I'm coding my own popup/confirm dialog, but the current problem is that I can still focus and click on stuff behind it (buttons, etc).
So I'd like to, when this popup is shown, the rest of the GUI is frozen and taking and inputs at all.

I'm not using the process_input function, just connecting the buttons signals, so is there a way to disable it easily for all controls under a specific node?

in Engine by (290 points)

Pause does not work?

nop, I can still click buttons

Godot 2 or 3?

On 2 tried with a button and a dialog and works just ignoring mouse (still, you need to get all the controls in a group to set the ignore mouse on and off, and grab and restore focus).

Do you have a small scene that does not work to test?

3 Answers

0 votes

I often use full screen size Control node for it.
if Control node has Stop Mouse flag on, it will stop event propagation under it.

- root control
   - some ui  # this will not get gui event.
   - full screen size control  # this node will consume all gui event.
      - some ui
by (9,800 points)

works for mouse, but I can still tab and enter to select other GUI controls behind

oh, I didn't think about that...

0 votes

i would use a combination of get_tree().set_pause(bool) and set_pause_mode(MODE)

By default all nodes have a pause mode on "INHERIT", this means it will have the same mode as it's parent. Take for example this tree:

GUI (Canvas Layer)
-menu (Control)
--buttona
--buttonb
--submenu (Control - hiden)
---buttonc
---cuttond

to enable main manu you call

get_tree().set_pause_mode(true)
GUI.set_pause_mode(PAUSE_MODE_PROCESS)
GUI.get_node("buttonb").connect("pressed",self,"_open_submenu")

this way your gui will work only with the visible childs of GUI

func _open_submenu():
    GUI.set_pause_mode(PAUSE_MODE_STOP)
    GUI.get_node("submenu").set_pause_mode(PAUSE_MODE_PROCESS)
    GUI.get_node("submenu").show()

Now only the visible childs of submenu will receibe input

by (63 points)
edited by
0 votes

If you use setfocusmode(FOCUS_NONE) the control cannot be focused.

Alternatively, if your popup has a single control to interact with, you can use the "focusexit" signal to call "grabfocus" on the main control. That way, nothing else can be focused.

by (18 points)
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.