Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | RaebaldKashban |
Hi all. I’m trying to get a simple plugin working but ran into a “method not found” error. Some background below.
The concept of the plugin is straightforward: I want a panel to appear when the user presses a key; then, I want the user to be able to close the panel by clicking a button. Here’s the code that is meant to achieve this:
The plugin code:
tool
extends EditorPlugin
var dialogue_editor_window_path = "res://addons/DialogueEditor/DialogueEditorWindow.tscn"
func _enter_tree():
InputMap.add_action("open_dialogue_editor")
var new_input_event = InputEventKey.new()
new_input_event.set_scancode(KEY_Q)
InputMap.action_add_event("open_dialogue_editor", new_input_event)
func _exit_tree():
InputMap.erase_action("open_dialogue_editor")
func _input(event):
if event.is_action_pressed("open_dialogue_editor"):
var dialogue_editor_window = load(dialogue_editor_window_path).instance()
dialogue_editor_window.get_node("Button").connect("pressed",dialogue_editor_window,"_on_button_pressed")
add_child(dialogue_editor_window)
The code for the panel that will be displayed.
extends Panel
func _on_button_pressed():
queue_free()
The panel scene itself is very simple–just a Panel node with a single Button as a child. The code above works for getting the panel opened, but when I click the “Close” button, I get the following error:
core/object.cpp:1260 - Error calling method from signal 'pressed': 'Panel(DialogueEditorWindow.gd)::_on_button_pressed': Method not found..
For some reason, the “pressed” signal doesn’t find the target method in the panel’s script, but it’s clearly there as far as I can tell. My assumption is that there’s something screwy going on here with the way that tools/editor plugins work, but I’m honestly at a loss. What’s strange is that Godot doesn’t complain when I try to connect the “pressed” signal to the method–doesn’t it usually do this if the method doesn’t exist?
Would appreciate any ideas you have. Thanks!