Skip to content

Conversation

YgorSouza
Copy link
Contributor

The override_text_color is now used when rendering text from a String or &str. This is consistent with the RichText variant and makes the option behave as advertised, taking precedence over WidgetVisuals and overriding the color for all text unless explicitly changed for a single widget (via RichText or LayoutJob).

The override_text_color is now used when rendering text from a String or
&str. This is consistent with the RichText variant and makes the option
behave as advertised, taking precedence over WidgetVisuals and
overriding the color for all text unless explicitly changed for a single
widget (via RichText or LayoutJob).
@YgorSouza
Copy link
Contributor Author

For the record, here is where RichText does the same thing (and why it didn't have the same problem as noted in the issue):

fn get_text_color(&self, visuals: &Visuals) -> Option<Color32> {
if let Some(text_color) = self.text_color {
Some(text_color)
} else if self.strong {
Some(visuals.strong_text_color())
} else if self.weak {
Some(visuals.weak_text_color())
} else {
visuals.override_text_color
}
}

let text_color = self.get_text_color(&style.visuals);

let text_color = text_color.unwrap_or(crate::Color32::PLACEHOLDER);

Copy link

github-actions bot commented Aug 9, 2025

Preview available at https://egui-pr-preview.github.io/pr/7439-override-text-color-priority
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@emilk emilk added bug Something is broken egui labels Aug 12, 2025
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Thanks! It would be great if you could add a simple snapshot test for this, e.g. in crates/egui_kittest/tests/regression_tests.rs

@YgorSouza YgorSouza requested a review from lucasmerlin as a code owner August 12, 2025 17:40
Copy link
Owner

Choose a reason for hiding this comment

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

Nice - thank you! ❤️

@emilk emilk added this to the 0.32.1 milestone Aug 14, 2025
@emilk emilk changed the title Fix override_text_color priority Fix override_text_color priority Aug 14, 2025
@emilk emilk merged commit 1937cc4 into emilk:main Aug 14, 2025
26 checks passed
emilk added a commit that referenced this pull request Aug 15, 2025
The override_text_color is now used when rendering text from a String or
&str. This is consistent with the RichText variant and makes the option
behave as advertised, taking precedence over WidgetVisuals and
overriding the color for all text unless explicitly changed for a single
widget (via RichText or LayoutJob).

* Closes <#7367>
* [x] I have followed the instructions in the PR template

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text inside buttons ignores override_text_color in 0.32.0
2 participants