forward_canvas_gui_input is never called

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Utnapishtim

I am building a plugin that will let me click and drag in the 2d viewport to place walls. Like the line tool in paint. In order to do this, I need to capture inputs inside the viewport in such a way that I get the world coordinates so that I know where to spawn and how to resize the wall.

But when I try to call forward_canvas_gui_input, nothing happens. What do I need to do to get get Godot to call this function, or failing that, what do I need to do to capture inputs in the editor for this tool?

I followed this tutorial and I’m at the point where I have a dock and I can call functions in _process(), _enter_tree(), and handle signals when ui elements are interacted with. Here is my script.

extends EditorPlugin

var enabled: bool = false
var grid_size: int = 1

var dock

func _enter_tree():
	dock = preload("res://addons/wall_draw/WallDraw.tscn").instance()
	add_control_to_dock(DOCK_SLOT_RIGHT_UL, dock)
	dock.get_node("Enabled").connect("toggled", self, "set_enabled")
	dock.get_node("GridSize").connect("item_selected", self, "set_grid_size")

func _exit_tree():

func set_enabled(button_pressed):
	if walls != null:
		enabled = button_pressed
		walls.enabled = enabled

func set_grid_size(index):
	if walls != null:
		grid_size = pow(2, index)
		walls.grid_size = grid_size

func handles(object):
	return false

func forward_canvas_gui_input(event):
	return true

print(object) in handles works as expected, but print(event) in forward_canvas_gui_input is never called. From what I’ve read in the documentation, the “return true” should be consuming all of my inputs, but everything else works just fine. I’ve tried restarting Godot multiple times and deactivating/reactivating the plugin but it changed nothing.

This is the only plugin/addon I have installed in this project. I am not using anything from the asset store.

:bust_in_silhouette: Reply From: Utnapishtim

I figured it out. It’s not clear in the documentation, but forward_canvas_gui_input is only called is handles is implemented and it returns true.