SWidget::RegisterActiveTimer

Registers an "active timer" delegate that will execute at some regular interval.

Windows
MacOS
Linux

References

Module

SlateCore

Header

/Engine/Source/Runtime/SlateCore/Public/Widgets/SWidget.h

Include

#include "Widgets/SWidget.h"

Source

/Engine/Source/Runtime/SlateCore/Private/Widgets/SWidget.cpp

Syntax

TSharedRef< FActiveTimerHandle > RegisterActiveTimer
(
    float TickPeriod,
    FWidgetActiveTimerDelegate TickFunction
)

Remarks

Registers an "active timer" delegate that will execute at some regular interval. TickFunction will not be called until the specified interval has elapsed once. A widget can register as many delegates as it needs. Be careful when registering to avoid duplicate active timers.

An active timer can be UnRegistered in one of three ways:

Call UnRegisterActiveTimer using the active timer handle that is returned here.

Have your delegate return EActiveTimerReturnType::Stop.

Destroying the widget

Active Timers

Slate may go to sleep when there is no user interaction for some time to save power. However, some UI elements may need to "drive" the UI even when the user is not providing any input (ie, animations, viewport rendering, async polling, etc). A widget notifies Slate of this by registering an "Active Timer" that is executed at a specified frequency to drive the UI. In this way, slate can go to sleep when there is no input and no active timer needs to fire. When any active timer needs to fire, all of Slate will do a Tick and Paint pass.

Returns

An active timer handle that can be used to UnRegister later.

Parameters

Parameter

Description

Period

The time period to wait between each execution of the timer. Pass zero to fire the timer once per frame. If an interval is missed, the delegate is NOT called more than once.

TimerFunction

The active timer delegate to call every Period seconds.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss