An old thread (but the only one with this information I could find).
Anyway, this was how I resolved setting the carets’ position within BP using @Monsieur_Dupond’s code.
In testing the widget loses focus after changing the caret location, so using a Set Keyboard Focus node on the widget in BP resolved this.
Also, since 5.1 some of @kevinraz’s code is deprecated, so here’s the full section replace:
MyMultiLineEditableText = SNew(SMultiLineEditableText)
.TextStyle(&WidgetStyle)
.AllowContextMenu(AllowContextMenu)
.IsReadOnly(GetIsReadOnly())
.OnCursorMoved(BIND_UOBJECT_DELEGATE(FOnCursorMoved, HandleEditableTextCursorMoved))
.SelectAllTextWhenFocused(GetSelectAllTextWhenFocused())
.ClearTextSelectionOnFocusLoss(GetClearTextSelectionOnFocusLoss())
.RevertTextOnEscape(GetRevertTextOnEscape())
.ClearKeyboardFocusOnCommit(GetClearKeyboardFocusOnCommit())
.VirtualKeyboardOptions(VirtualKeyboardOptions)
.VirtualKeyboardDismissAction(VirtualKeyboardDismissAction)
.OnTextChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnTextChanged))
.OnTextCommitted(BIND_UOBJECT_DELEGATE(FOnTextCommitted, HandleOnTextCommitted))
;
.cpp
//Monsieur_Dupond
void UMDMultiLineEditableText::GoTo(const FTextLocation& NewLocation)
{
MyMultiLineEditableText->GoTo(NewLocation);
}//Only way to use BP to then call the above function to make it switch to the new location.
void UMDMultiLineEditableText::NewCursorLocation(int32 LineIndex, int32 LineOffset)
{
MyMultiLineEditableText->GoTo(FTextLocation(LineIndex,LineOffset));
}
.h
//Monsieur_Dupond
void GoTo(const FTextLocation& NewLocation);UFUNCTION(BlueprintCallable)
void NewCursorLocation(int32 LineIndex, int32 LineOffset);
I do not claim to be a C++ expert, but the above worked for me