Godot Version
4.2.1
Question
ok I have two kinds of code that I am working on. The first code involves creating buttons for a search menu that when clicked navigate to a location (all this code works but I get an error. If I am understanding the error it is basically saying that the button requires a signal, but the buttons are working as intended?
func _create_action_list()->void:
for item in search_menu_list.get_children():
item.queue_free()
for names in names_functions:
var button=search_menu_button.instantiate()
button.text=names
button.name=names
search_menu_list.add_child(button)
button.pressed.connect(_on_button_pressed.bind(button.name))
func _on_button_pressed(button):
if system_menu:
system_menu.call("_on_search_button_pressed",button)
else:
print("failed to find button")
This is the error (like to remind that the code works even without the button containing the signal, so I added it just to make the error go away, but I am confused why its acting like this)
E 0:00:02:0221 search_menu.gd:44 @ _create_action_list(): In Object of type āButtonā: Attempt to connect nonexistent signal āsearch_button_pressedā to callable āButton(search_menu_button.gd)::_on_search_button_pressedā.
<C++ Error> Condition ā!signal_is_validā is true. Returning: ERR_INVALID_PARAMETER
<C++ Source> core/object/object.cpp:1344 @ connect()
search_menu.gd:44 @ _create_action_list()
search_menu.gd:38 @ _ready()
seed_system_menu_settings.gd:29 @ _on_seed_start_button_pressed()
I did something similar with rebinding keys (it makes the buttons that are editable), but this code didnt flag the need for signals.
func _create_action_list()->void:
for item in action_list.get_children():
item.queue_free()
for action in input_actions: #when I have the "dictionary" set up <- insert in place of "InputMap.get_actions()"
var button=input_button_scene.instantiate()
var action_label=button.find_child("Action Label")
var input_label=button.find_child("Input Label")
action_label.text=input_actions[action] #when dictionary setup this must match the "dictionary"[action]
var events=InputMap.action_get_events(action)
if events.size()>0:
input_label.text=events[0].as_text().trim_suffix(" (Physical)")
else:
input_label.text=""
action_list.add_child(button)
button.pressed.connect(_on_input_button_pressed.bind(button,action))
I am curious about the difference~ any help is appreciated. Its already techically resolved? but it bugs me I have to put a signal script onto buttons that never get used. if possible to work around that issue im all ears (might save me trouble in the future).