ppizarror / pygame-menu

A menu for pygame. Simple, and easy to use
https://pygame-menu.readthedocs.io/
Other
544 stars 141 forks source link

[FEAT] Button active state #417

Closed leestarb closed 1 year ago

leestarb commented 2 years ago

Is your feature request related to a problem? Please describe. I need an ability to disable a button:

Describe the solution you'd like A clear and concise description of what you want to happen. Add methods to enable/disable button Also add this as disabled: bool consturctor parameter!

Describe alternatives you've considered No good

Additional context This project is actually a really good thing in my life! :-)

ppizarror commented 2 years ago

Check out also the readonly widget property:

button = menu.add.button(...)
button.readonly = True

Readonly ignores all events of widgets (it should...). This can also be another solution. Then you can apply a different background color for buttons. If you plan to combine these two solutions it would be great =)

Greetings!

leestarb commented 2 years ago

Great. It works! =)

leestarb commented 2 years ago

Btw, how to change the color of text when the widget is readonly?

ppizarror commented 1 year ago

Hello, sorry for the delay... hope you've already solved this issue.

For any upcoming person with this same problem: You can use the Theme.readonly_color and readonly_selected_color attributes. Also, you can manually set set_background_color() depending on the read-only status.