In the .h:
UPROPERTY(meta = (BindWidget))
class UEditableTextBox* ServerHostName;
In the .cpp:
if (!ensure(ServerHostName != nullptr)) return false;
ServerHostName->OnTextChanged.AddDynamic(this, &UMainMenu::ValidateServerNameText()); // ERROR
Please can you tell me how to correctly set this up?
I’d like the function ‘ValidateServerNameText()’ to fire each time the text is changed.
Where does this line have to go:
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEditableTextBoxChangedEvent, const FText&, Text);
I’d like my function to be able to count the characters of the input text and clamp them to a MaxCharacters variable.
Therefore does my function have to have these arguments:
ValidateServerNameText(const FText&, Text)?
Hey !
OnTextChanged is of type FOnEditableTextBoxChangedEvent ( as you noticed )
this mean it pass an arg to the binded method ( const FText& Text, as you pasted )
so you need UMainMenu::ValidateServerNameText to return void and take an arg, but you also need it to be a “UFUNCTION” to be able to bind it :
if you set text from here ( to clamp it or anything ), it will make a recursive call of your event, it’s not really a problem, but if you have some heavy task, take care of that with a bool to prevent that