Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix font_hover_pressed_color and icon_hover_pressed_color not working for no stylebox use on Button #97335

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

SlienCode
Copy link
Contributor

Fixes #83393

I encountered this as I was working on my own project and I highly doubt this is a design choice. The issue is basically that the Button node cannot make use of font_hover_pressed_color and icon_hover_pressed_color unless a hover_pressed stylebox is assigned to it. This is especially noticeable whenever you are working with toggleable buttons. I now changed it so that you don't need to have a hover_pressed stylebox to make use of font_hover_pressed_color and icon_hover_pressed_color.

colors buttons

show

Code

I think it is evident this was an oversight in the previous code judging by the commented line which suggests that the if statement was put in place as an edge case for CheckButton and CheckBox. This if statement and the comment itself were most likely copied from the function Button::_get_current_stylebox() of the same file (old line 145) which does need to make sure the proper stylebox is assigned. In our case however, we do not need the stylebox in order to make use of this feature so I simply removed the if statement. As you can see, CheckButton and CheckBox are unaffected by this change so the if statement didn't have a reason to be there in the first place.

…king for no stylebox use on `Button`

You now don't need to have a `hover_pressed` stylebox to make use of `font_hover_pressed_color` and `icon_hover_pressed_color`.
Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code was intentional. Button has toggle mode disabled by default, unlike CheckButton and CheckBox, for which the code was meant. The logic just existed in the parent class.

However I see no reason why it has to be like that. The colors are defined for Button, so the buttons still look correctly after this change. These colors were basically unused, which is weird.

@Repiteo Repiteo modified the milestones: 4.x, 4.4 Oct 23, 2024
@clayjohn clayjohn merged commit cb618e4 into godotengine:master Oct 25, 2024
19 checks passed
@clayjohn
Copy link
Member

Thank you! And congratulations on your first merged contribution! 🎉

@SlienCode
Copy link
Contributor Author

Thank you and I really appreciete having it reviewed and merged. Have a good one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

font_hover_pressed_color doesn't work on Button
5 participants