Multi-state button


Before I roll my own: is there a multi-state or n-state button component already? I need a button that can have three states (off, hot, cold). So every time it’s clicked it goes to the next state and cycles once it reaches the cold state and gets clicked again.

It’s trivial to implement, I just want to keep on using the base classes as much as possible and avoid unnecessary repetition (DRY principle).


can we see your trivial implementation?


I haven’t written it, yet, as I was hoping something like that already exists as a base-class. Like the toggle button already exists, so I hopped that default Button class might do something like that.

Yes, it is trivial to implement. Each click simply increases a value by 1 and uses a modulo to wrap the value around. That way it can be used for a toggle button or a tri-state or any n-state you want.


Hi, no, there are no multistate buttons implemented. As you say though, they’re quite easy to implement with minimal effort.


Thanks for confirming. I’ve actually just finished rolling my own :smiley: