Best way to handle (button) Event Listeners?

I wonder if there is an optimal way to handle button event listeners, like for example in a menu screen with a lot of different buttons, so when you click one button all other buttons can’t be clicked on. How is your way of handling this kind of things?

I use a check, like pushed=true and I always check in each event listener function for each button if pushed is true, but I think this is not the optimal way to do this kind of thing. Isn’t it better to “turn off” all other buttons instead, while the function for the pushed button is active?

Daniela

I wouldn’t say it’s bad

If yoy want other way then maybe event-based one? You make button dispatch custom events and other button losten to it and perform actions if event comes.

Thx! I only thought about it as “bad” because it can get complicated to keep track of the ‘pushed’ variable with a lot of buttons and things to click on a screen.

I wouldn’t say it’s bad

If yoy want other way then maybe event-based one? You make button dispatch custom events and other button losten to it and perform actions if event comes.

Thx! I only thought about it as “bad” because it can get complicated to keep track of the ‘pushed’ variable with a lot of buttons and things to click on a screen.