FTextBlockStyle does not work at SEditableTextBox
This posting is based on engine version 5.3
Symptom
- When we use
SEditableTextBox - If we set an
FTextBlockStyleinside theFEditableTextBoxStyle - And if you set this style at the construction stage of the Slate statement, like below,
FTextBlockStyleabove, which is inside theFEditableTextBoxStyle, will not be applied.
Cause
The cause lies in SEditableTextBox::Construct()
SEditableTextBoxdoes not pass styles when creatingTSharedPtr< SEditableText > EditableTextinsideConstruct(). GitHub Link- Instead, in earlier timing in the
Construct(),SEditableTextBoxtry to set the style by calling a separate function,SEditableTextBox::SetStyle(). GitHub Link SEditableTextBox::SetStyle()callsSEditableTextBox::SetTextBlockStyle()at the end, and this function callsSEditableText::SetTextBlockStyle()to setFTextBlockStyle. GitHub Link- Here, before
SEditableTextBox::SetTextBlockStyle()callsSEditableText::SetTextBlockStyle(), the part that checks the validity ofTSharedPtr< SEditableText > EditableTextthere is. If it is invalid, ````SEditableText::SetTextBlockStyle()will not be executed. And since this timing is before the creation ofTSharedPtr< SEditableText > EditableText, the setting ofFTextBlockStyle``` is skipped. GitHub Link - And without further action,
SEditableTextBox::Construct()ends. - As a result, in the construction of the
SEditableText, the setting ofFTextBlockStyleis always skipped.
Workaround
After the construction, because that validation check will succeed, so after the construction if we call the SEditableTextBox::SetStyle() or SEditableTextBox::SetTextBlockStyle(), we can apply the FTextBlockStyle to SEditableTextBox.
Like this:
I’ve been thinking about sending a pull request, but I’m hesitant because I’ve had several heartbreaking experiences with pull requests recently. The fact that this isn’t that lethal also makes me hesitate.
But for me, it was critical.
tags
Within
"Unreal Engine"
Within
"Blog"
Next:
Unreal Engine UI