0

I have Option Button that contains several items. Changing the current item is connected to a function that performs logic. When I do it by mouse it works as expected. But when I try do it in code (for example, in _ready() functions, then the signal is not called and logic function is not called:

func _ready() -> void:
    $Panel/Button.select(randi() % 4)

I can emit my logic function manually:

func _ready() -> void:
    $Panel/Button.select(randi() % 4)
    $Panel/Button.emit_signal("item_selected", $Panel/Button.selected)

But is there more convenient way to change control property with emitting signal inside class?

Shatur95
  • 93
  • 1
  • 9
  • If I understand correctly, you're trying to connect a signal through code only? If so, I think you have to connect the objects that you want to respond to the signal using the `Object.connect()` method. Example is something like this: `func ready(): connect("item_selected", self, "do_something_with_item)`. – Christopher Bennett May 15 '19 at 07:15
  • @ChristopherBennett, no, `item_selected` is alredy connected in the editor GUI to my logic function. But if I change the item from the code, then the logic function will not be called :( – Shatur95 May 15 '19 at 10:24
  • 1
    Select will not emit the selected signal. It looks like _selected(id) is exposed to gdscript and that will both call select and emit the signal. Also, calling emit signal here is fine. – hola Jul 07 '19 at 18:33

0 Answers0