Minimap - SubViewportContainer stops event handling

4.1.1.stable

Hello friends of free game development.

I wanted to build a minimap with mouse panning - click, drag… map moves, you know what i mean. Therefore i built the following scene which works as intended when executed alone but fails when attached as child to my GUI scene.

It randomly stops receiving _input(event) calls, no pattern, just randomly when using panning the window. Sometimes it starts again just to stop moments later. Sporadically and only when attached as child (of an hboxcontainer).

Scene:
SubViewportContainer (script attached)

  • SubViewPort
  • Camera2D

Script:

...
func _input(event):

	if !get_global_rect().has_point(get_global_mouse_position()):
		dragging = false 
		return  
	
	if event is InputEventMouseButton:
		if event.button_index == 1: 
			if event.pressed:
				dragging = true
				mouse_old = get_local_mouse_position()
			else:
				dragging = false 
				mouse_now = Vector2.ZERO
				mouse_old = Vector2.ZERO

		elif event.button_index == 5: # 5 = MOUSE_BUTTON_WHEEL_DOWN
			_zoom_camera(-zoom_stepsize)
		elif event.button_index == 4: # 4 = MOUSE_BUTTON_WHEEL_UP
			_zoom_camera(zoom_stepsize)
	
	# Panning behaviour here
	elif event is InputEventMouseMotion and dragging:
		mouse_now = get_local_mouse_position()
		delta_mouse = (mouse_now - mouse_old) #* camera.zoom
		camera.position -= delta_mouse * panning_sensitivity
		mouse_old = mouse_now

Would you please explain me why this does not work as intended. Im pretty sure this should work with a small fix but i just don’t progress since frustrating hours. My best guess is that the event gets consumed somehow but i don’t know why this should happen (filter is set to pass).

Thanks in advance
Chris

Edit: Solved
In SubViewPort → GUI → Disable Input = True did the trick.
Could someone please explain this?

My guess would be that the input does not be consumed by the SubViewport itself and is passed on to the parent which handles the event in the script.