I’m looking for an overridable function such as “OnVisibilityChanged”. (I’d like to use it to trigger a refresh of some data when the widget is set to visible.)
I would also like to know this
There is no Visibility Changed event, sry. Make a Custom Event that Handles Visibility and some Cleanup afterwards or a Custom Event that does the Cleanup and call it right after Set Visibility. Up to you.
In UE 4.27.2, there are the following events for this
/** Called when the visibility has changed */
UPROPERTY(BlueprintAssignable, Category = "Appearance|Event")
FOnVisibilityChangedEvent OnVisibilityChanged;
DECLARE_EVENT_OneParam(UUserWidget, FNativeOnVisibilityChangedEvent, ESlateVisibility);
FNativeOnVisibilityChangedEvent OnNativeVisibilityChanged;
I use it in C++ as follows:
void
UFWidgetSettings::NativeConstruct()
{
Super::NativeConstruct();
// ...
OnNativeVisibilityChanged.AddUObject(this, &UFWidgetSettings::Callback_OnVisiblityChanged);
}
void
UFWidgetSettings::Callback_OnVisiblityChanged(ESlateVisibility NewVisibility)
{
//...
}
cheers