diff --git a/include/eepp/graphics/richtext.hpp b/include/eepp/graphics/richtext.hpp index c3c40930a..b7e2c0b65 100644 --- a/include/eepp/graphics/richtext.hpp +++ b/include/eepp/graphics/richtext.hpp @@ -167,7 +167,7 @@ class EE_API RichText : public Drawable { std::vector mLines; FontStyleConfig mDefaultStyle; TextSelectionRange mSelection{ 0, 0 }; - Color mSelectionColor{ Color::Transparent }; + Color mSelectionColor{ Color::White }; Color mSelectionBackColor{ 0, 0, 255, 150 }; Uint32 mAlign{ TEXT_ALIGN_LEFT }; Float mMaxWidth{ 0.f }; diff --git a/src/eepp/graphics/richtext.cpp b/src/eepp/graphics/richtext.cpp index ab986ba0c..530b36e61 100644 --- a/src/eepp/graphics/richtext.cpp +++ b/src/eepp/graphics/richtext.cpp @@ -58,6 +58,7 @@ void RichText::draw( const Float& X, const Float& Y, const Vector2f& scale, cons Overloaded{ [&]( const std::shared_ptr& text ) { + bool selectionApplied = false; if ( mSelectionColor != Color::Transparent ) { TextSelectionRange spanSel = { std::clamp( mSelection.start, span.startCharIndex, @@ -71,8 +72,7 @@ void RichText::draw( const Float& X, const Float& Y, const Vector2f& scale, cons text->setFillColor( mSelectionColor, (Uint32)std::min( spanSel.start, spanSel.end ), (Uint32)std::max( spanSel.start, spanSel.end ) - 1 ); - } else { - text->setFillColor( text->getFontStyleConfig().FontColor ); + selectionApplied = true; } } @@ -84,6 +84,9 @@ void RichText::draw( const Float& X, const Float& Y, const Vector2f& scale, cons std::trunc( Y + ( line.y + pos.y ) * scale.y ), scale, rotation, effect, rotationCenter, scaleCenter ); } + + if ( selectionApplied ) + text->invalidateColors(); }, [&]( const std::shared_ptr& drawable ) { if ( drawable ) {