FTextBlockStyle does not work at SEditableTextBox
This posting is based on engine version 5.3
Symptom
- When we use
SEditableTextBox
- If we set an
FTextBlockStyle
inside theFEditableTextBoxStyle
- And if you set this style at the construction stage of the Slate statement, like below,
FTextBlockStyle
above, which is inside theFEditableTextBoxStyle
, will not be applied.
Cause
The cause lies in SEditableTextBox::Construct()
SEditableTextBox
does not pass styles when creatingTSharedPtr< SEditableText > EditableText
insideConstruct()
. GitHub Link- Instead, in earlier timing in the
Construct()
,SEditableTextBox
try 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 > EditableText
there is. If it is invalid, ````SEditableText::SetTextBlockStyle()will not be executed. And since this timing is before the creation of
TSharedPtr< SEditableText > EditableText, the setting of
FTextBlockStyle``` is skipped. GitHub Link - And without further action,
SEditableTextBox::Construct()
ends. - As a result, in the construction of the
SEditableText
, the setting ofFTextBlockStyle
is 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