#UI Event bubble up?

1 messages · Page 1 of 1 (latest)

dense stirrup
#

Hey is there any way for UI events to like "bubble up?" So I can handle them at a higher level of my tree? My use-case in particular is a group of option buttons, but being able to handle them like this would be useful generally.

lunar harbor
#

You could connect to their gui_input signal to handle it from elsewhere

dense stirrup
#

Yeah, looking at that but it seems less than ideal. What I'd really like is for buttons toggled event to bubble up.

hasty coral
#

You could create your own signals

dense stirrup
#

What I'm looking to avoid doing is having to wire anything up in the child controls themselves.

#

I think I've settled on this approach:

public void OnReady() {
foreach(Button childButton in GetChildren().OfType<Button>()) {
  int rate = childButton.GetMeta("Rate").As<int>();
  childButton.Toggled += toggleState => StrategicTimer.TimeMultiplier = toggleState ? rate : 0;
  }
}
#

Which I don't love, but should work.