Button Input on pause

I got a stack overflow. it says I should check the infinite recursion which I guess is the function you showed me

Stack overflow (stack size: 1024). Check for infinite recursion in your script.

extends SubViewport


func _input(event: InputEvent) -> void:
	push_input(event)

I haven’t looked very closely but if you use tweens to animate the buttons I believe the problem could be with the them. They need to have their process mode set separately. They will not inherit the process mode from the whatever node creates them.

tween.set_pause_mode(Tween.TWEEN_PAUSE_PROCESS)

If you have infinite recursion, are you sure that your input is not used to 1. open the pause menu, 2. press the continue button, 3. open the pause menu again etc etc? Especially if it is the continue button that spawns in focused.

Could you try call_deferred the grab_focus() of the button?

the resum buttoj is suppossed to be focused when paused, but it’s not focused, there is just no Input

Oh you keep it invisible then toggle on and off? So not a ready.

In that case connect the grab focus function to the visibility changed signal or the root node toggled visible/invisible. If toggled on, grab focus.

Making something visible or kinvisible back and forth messes with the focus in my experience.

no, it’s always visible. What I said is that when the scene tree isnt paused, then it works perfectly fine, else? it doesnt work. If you want more details, please check my precious comments

Interesting. I called it from a parent class. I thought that was overly complex, so I tried to simplify it for you. However, it seems you have to, because otherwise you get infinite recursion.

  1. Delete that script.
  2. Right-click on the SubViewport and select %Access as Unique Name
  3. Add a script to Main:
@onready var sub_viewport: SubViewport = %SubViewport


func _input(event: InputEvent) -> void:
	sub_viewport.push_input(event)

that didnt work