Navigation
API > API/Runtime > API/Runtime/SlateCore > API/Runtime/SlateCore/Widgets
Inheritance Hierarchy
- FSlateControlledConstruction
- TSharedFromThis
- SWidget
- SCompoundWidget
- IMultiReplicationStreamEditor
- IPinnedCommandList
- IReplicationStreamViewer
- IReplicationStreamEditor
- IRewindDebuggerView
- ISocketManager
- SAppIconWidget
- SBasicFilterBar
- SBonePairRow::SSkeletonWidget
- SBreadcrumbTrailBase
- SColorTrash
- SCurvePickerWidget
- SDMXPixelMappingScreenLayout
- SGenericDialogWidget
- SIKRigHierarchyItem
- SItemSelector
- SLiveLinkBoneTreeMenu
- SMultiBlockBaseWidget
- SNiagaraAssetBrowser
- SNiagaraAssetTag
- SNiagaraGraphActionWidget
- SNiagaraHierarchyCategory
- SNiagaraHierarchySection
- SNiagaraParameterMenu
- SNiagaraAddParameterFromPinMenu
- SNiagaraFunctionSpecifierNDCVariablesMenu
- SNiagaraParameterName
- SNiagaraPinTypeSelector
- SNiagaraTemplateTabBox
- SNotificationItem
- SObjectTreeGraphToolboxEntry
- SPreviewSceneProfileSelector
- SScrollBox
- STableViewBase
- SListView
- SAssetColumnView
- SAssetListView
- SCommonListView
- SMLDeformerCurvePickerListView
- SMLDeformerInputCurveListWidget
- SThrobber
- SUserWidget
- SLeafWidget
- SPanel
- SBoxPanel
- SHorizontalBox
- SStackBox
- SSplitter
- SThemeColorBlocksBar
References
| Module | SlateCore |
| Header | /Engine/Source/Runtime/SlateCore/Public/Widgets/SWidget.h |
| Include | #include "Widgets/SWidget.h" |
Syntax
class SWidget :
public FSlateControlledConstruction ,
public TSharedFromThis< SWidget >
Remarks
HOW TO DEPRECATE SLATE_ATTRIBUTES
SLATE_ATTRIBUTE(ECheckBoxState, IsChecked)
UE_DEPRECATED(4.xx, "Please use IsChecked(TAttribute
// This version would prevent ambiguous conversions. FArguments& IsChecked(ECheckBoxState InIsChecked) { _IsChecked = InIsChecked; return Me(); } Abstract base class for Slate widgets.
STOP. DO NOT INHERIT DIRECTLY FROM WIDGET!
Inheritance: Widget is not meant to be directly inherited. Instead consider inheriting from LeafWidget or Panel, which represent intended use cases and provide a succinct set of methods which to override.
SWidget is the base class for all interactive Slate entities. SWidget's public interface describes everything that a Widget can do and is fairly complex as a result.
Events: Events in Slate are implemented as virtual functions that the Slate system will call on a Widget in order to notify the Widget about an important occurrence (e.g. a key press) or querying the Widget regarding some information (e.g. what mouse cursor should be displayed).
Widget provides a default implementation for most events; the default implementation does nothing and does not handle the event.
Some events are able to reply to the system by returning an FReply, FCursorReply, or similar object.
Variables
| Type | Name | Description | |
|---|---|---|---|
| uint8: 1 | bCanHaveChildren | Can the widget ever support children? This will be false on SLeafWidgets, rather than setting this directly, you should probably inherit from SLeafWidget. | |
| uint8: 1 | bCanSupportFocus | Can the widget ever support keyboard focus | |
| uint8: 1 | bClippingProxy | Some widgets might be a complex hierarchy of child widgets you never see. | |
| uint8: 1 | bHasCustomPrepass | ||
| uint8: 1 | bHasRelativeLayoutScale | ||
| uint8: 1 | bVolatilityAlwaysInvalidatesPrepass | If this widget should always invalidate the prepass step when volatile | |
| EWidgetClipping | Clipping | Set to true if all content of the widget should clip to the bounds of this widget. | |
| FMargin | CullingBoundsExtension | Can be used to enlarge the culling bounds of this widget (pre-intersection), this can be useful if you've got children that you know are using rendering transforms to render outside their standard bounds, if that happens it's possible the parent might be culled before the descendant widget is entirely off screen. | |
| EWidgetPixelSnapping | PixelSnappingMethod | When set to EPixelSnappingMethod::SnapToPixel, the widget is drawn at the nearest pixel. | |
| TOptional< float > | PrepassLayoutScaleMultiplier | ||
| float | RenderOpacity | The opacity of the widget. Automatically applied during rendering. |
Constructors
| Type | Name | Description | |
|---|---|---|---|
SWidget () |
Hidden default constructor.Use SNew(WidgetClassName) to instantiate new widgets. |
Destructors
| Type | Name | Description | |
|---|---|---|---|
~SWidget () |
Dtor ensures that active timer handles are UnRegistered with the SlateApplication. |
Functions
| Type | Name | Description | |
|---|---|---|---|
| TAttribute< EVisibility > | AccessWidgetVisibilityAttribute
(
const TSharedRef< SWidget >& Widget |
Protected static helper to allow widgets to access the visibility attribute of other widgets directly | |
| void | AddMetadata
(
const TSharedRef< MetaDataType >& AddMe |
Add metadata to this widget. | |
| const FSlateInvalidationRoot * | |||
| TSharedPtr< SWidget > | |||
| bool | Recalculates and caches volatility and returns 'true' if the volatility changed. | ||
| bool | |||
| bool | Is this widget derivative of SWindow | ||
| void | ArrangeChildren
(
const FGeometry& AllottedGeometry, |
Non-virtual entry point for arrange children. | |
| void | AssignParentWidget
(
TSharedPtr< SWidget > InParent |
||
| void | CacheDesiredSize
(
float InLayoutScaleMultiplier |
The system calls this method. | |
| void | Recalculates volatility of the widget and caches the result. | ||
| FSlateRect | CalculateCullingAndClippingRules
(
const FGeometry& AllottedGeometry, |
Calculates what if any clipping state changes need to happen when drawing this widget. | |
| FVector2D | ComputeDesiredSize
(
float LayoutScaleMultiplier |
Compute the ideal size necessary to display this widget. | |
| EFlowDirection | Establishes a new flow direction potentially, if this widget has a particular preference for it and all its children. | ||
| bool | Recomputes the volatility of the widget. | ||
| bool | ConditionallyDetatchParentWidget
(
SWidget* InExpectedParent |
||
| bool | CustomPrepass
(
float LayoutScaleMultiplier |
||
| FChildren * | Returns all Widgets, including widget hidden from the invalidation system. | ||
| uint32 | |||
| void | EnableToolTipForceField
(
const bool bEnableForceField |
Sets whether this widget is a "tool tip force field". | |
| bool | FindChildGeometries
(
const FGeometry& MyGeometry, |
Find the geometry of a descendant widget. | |
| void | FindChildGeometries_Helper
(
const FGeometry& MyGeometry, |
Actual implementation of FindChildGeometries. | |
| FGeometry | FindChildGeometry
(
const FGeometry& MyGeometry, |
Find the geometry of a descendant widget. | |
| int32 | FindChildUnderMouse
(
const FArrangedChildren& Children, |
||
| int32 | FindChildUnderPosition
(
const FArrangedChildren& Children, |
||
| void | ForceVolatile
(
bool bForce |
Should this widget always appear as volatile for any layout caching host widget. | |
| FChildren * | Returns the children (if any) of this widget that are used by the invalidation system. | ||
| TArray< TSharedRef< MetaDataType > > | Get all metadata of the type provided. | ||
| const FGeometry & | |||
| bool | GetCanTick () |
||
| FChildren * | GetChildren () |
Returns the useful children (if any) of this widget. | |
| EWidgetClipping | GetClipping () |
||
| FName | |||
| FMargin | |||
| const TOptional< FSlateClippingState > & | Returns the clipping state to clip this widget against its parent | ||
| TOptional< EMouseCursor::Type > | GetCursor () |
The cursor to show when the mouse is hovering over this widget. | |
| UE::Slate::FDeprecateVector2DResult | |||
| FSlateColor | |||
| TSlateAttributeRef< bool > | |||
| EFlowDirectionPreference | Gets the desired flow direction for the layout. | ||
| const FSlateBrush * | |||
| FSlateColor | |||
| TSlateAttributeRef< bool > | |||
| uint64 | GetId () |
||
| TSharedPtr< MetaDataType > | GetMetaData () |
Get the metadata of the type provided. | |
| const FGeometry & | Gets the last geometry used to Tick the widget. | ||
| TSharedPtr< SWidget > | |||
| const FSlateWidgetPersistentState & | |||
| EWidgetPixelSnapping | |||
| float | |||
| const FWidgetProxyHandle | |||
| FString | |||
| float | GetRelativeLayoutScale
(
const int32 ChildIndex, |
What is the Child's scale relative to this widget. | |
| float | |||
| const TOptional< FSlateRenderTransform > & | |||
| TSlateAttributeRef< TOptional< FSlateRenderTransform > > | |||
| UE::Slate::FDeprecateVector2DResult | |||
| TSlateAttributeRef< FVector2D > | |||
| UE::Slate::FDeprecateVector2DResult | |||
| TOptional< FSlateRenderTransform > | |||
| TStatId | GetStatID
(
bool bForDeferredUse |
||
| FName | GetTag () |
||
| const FGeometry & | Gets the last geometry used to Tick the widget. | ||
| TSharedPtr< IToolTip > | GetToolTip () |
||
| FName | GetType () |
||
| FString | |||
| EVisibility | This widget can be visible but if a parent is hidden or collapsed, it would not show on screen. | ||
| TSlateAttributeRef< EVisibility > | |||
| EWindowZone::Type | Called when the mouse is moved over the widget's window, to determine if we should report whether OS-specific features should be active at this location (such as a title bar grip, system menu, etc.) Usually you should not need to override this function. | ||
| bool | Does this widget have any active timers? | ||
| bool | HasAnyUpdateFlags
(
EWidgetUpdateFlags FlagsToCheck |
||
| TOptional< EFocusCause > | Gets whether or not any users have this widget focused, and if so the type of focus (first one found). | ||
| bool | |||
| bool | |||
| bool | Checks to see if this widget currently has the keyboard focus | ||
| bool | Checks to see if this widget is the current mouse captor | ||
| bool | HasMouseCaptureByUser
(
int32 UserIndex, |
Checks to see if this widget has mouse capture from the provided user. | |
| bool | |||
| bool | |||
| TOptional< EFocusCause > | HasUserFocus
(
int32 UserIndex |
Gets whether or not the specified users has this widget focused, and if so the type of focus. | |
| bool | HasUserFocusedDescendants
(
int32 UserIndex |
Gets whether or not the specified users has this widget or any descendant focused. | |
| void | Invalidate
(
EInvalidateWidgetReason InvalidateReason |
Invalidates the widget from the view of a layout caching widget that may own this widget. | |
| void | InvalidateChildRemovedFromTree
(
SWidget& Child |
Called when a child is removed from the tree parent's widget tree either by removing it from a slot. | |
| bool | |||
| bool | IsChildWidgetCulled
(
const FSlateRect& MyCullingRect, |
Tests if an arranged widget should be culled. | |
| bool | Is the widget construction completed (did we called and returned from the Construct() function) | ||
| bool | |||
| bool | IsEnabled () |
||
| bool | IsHovered () |
IsHovered used to be virtual. | |
| bool | |||
| bool | |||
| bool | IsVolatile () |
Whether or not a widget is volatile and will update every frame without being invalidated | |
| bool | This widget is volatile because its parent or some ancestor is volatile | ||
| void | In fast path, if the widget is mark, do a full Prepass on its next update to calculate it's desired size. | ||
| bool | NeedsPrepass () |
LAYOUT | |
| FReply | OnAnalogValueChanged
(
const FGeometry& MyGeometry, |
Called when an analog value changes on a button that supports analog | |
| void | Called when clipping is changed. | ||
| FCursorReply | OnCursorQuery
(
const FGeometry& MyGeometry, |
The system asks each widget under the mouse to provide a cursor. This event is bubbled. | |
| FReply | OnDragDetected
(
const FGeometry& MyGeometry, |
Called when Slate detects that a widget started to be dragged. | |
| void | OnDragEnter
(
const FGeometry& MyGeometry, |
DRAG AND DROP (DragDrop) Called during drag and drop when the drag enters a widget. | |
| void | OnDragLeave
(
const FDragDropEvent& DragDropEvent |
Called during drag and drop when the drag leaves a widget. | |
| FReply | OnDragOver
(
const FGeometry& MyGeometry, |
Called during drag and drop when the the mouse is being dragged over a widget. | |
| FReply | OnDrop
(
const FGeometry& MyGeometry, |
Called when the user is dropping something onto a widget; terminates drag and drop. | |
| void | All the key (keyboard, gamepay, joystick, etc.) input from this frame has been routed. | ||
| void | All the pointer (mouse, touch, stylus, etc.) events from this frame have been routed. | ||
| void | OnFocusChanging
(
const FWeakWidgetPath& PreviousFocusPath, |
Called whenever a focus path is changing on all the widgets within the old and new focus paths | |
| void | OnFocusLost
(
const FFocusEvent& InFocusEvent |
Called when this widget loses focus. This event does not bubble. | |
| FReply | OnFocusReceived
(
const FGeometry& MyGeometry, |
KEY INPUT Called when focus is given to this widget. This event does not bubble. | |
| FReply | OnKeyChar
(
const FGeometry& MyGeometry, |
Called after a character is entered while this widget has keyboard focus | |
| FReply | Called after a key is pressed when this widget has focus (this event bubbles if not handled) | ||
| FReply | Called after a key is released when this widget has focus | ||
| TOptional< TSharedRef< SWidget > > | OnMapCursor
(
const FCursorReply& CursorReply |
After OnCursorQuery has specified a cursor type the system asks each widget under the mouse to map that cursor to a widget. | |
| FReply | OnMotionDetected
(
const FGeometry& MyGeometry, |
Called when motion is detected (controller or device) e.g. Someone tilts or shakes their controller. | |
| FReply | OnMouseButtonDoubleClick
(
const FGeometry& InMyGeometry, |
Called when a mouse button is double clicked. Override this in derived classes. | |
| FReply | OnMouseButtonDown
(
const FGeometry& MyGeometry, |
MOUSE INPUT The system calls this method to notify the widget that a mouse button was pressed within it. | |
| FReply | OnMouseButtonUp
(
const FGeometry& MyGeometry, |
The system calls this method to notify the widget that a mouse button was release within it. | |
| void | OnMouseCaptureLost
(
const FCaptureLostEvent& CaptureLostEvent |
Called when this widget had captured the mouse, but that capture has been revoked for some reason. | |
| void | OnMouseEnter
(
const FGeometry& MyGeometry, |
The system will use this event to notify a widget that the cursor has entered it. | |
| void | OnMouseLeave
(
const FPointerEvent& MouseEvent |
The system will use this event to notify a widget that the cursor has left it. | |
| FReply | OnMouseMove
(
const FGeometry& MyGeometry, |
The system calls this method to notify the widget that a mouse moved within it. | |
| FReply | OnMouseWheel
(
const FGeometry& MyGeometry, |
Called when the mouse wheel is spun. This event is bubbled. | |
| FNavigationReply | OnNavigation
(
const FGeometry& MyGeometry, |
Called when navigation is requested e.g. Left Joystick, Direction Pad, Arrow Keys can generate navigation events. | |
| FReply | OnPreviewKeyDown
(
const FGeometry& MyGeometry, |
Called after a key is pressed when this widget or a child of this widget has focus If a widget handles this event, OnKeyDown will not be passed to the focused widget. | |
| FReply | OnPreviewMouseButtonDown
(
const FGeometry& MyGeometry, |
Just like OnMouseButtonDown, but tunnels instead of bubbling. | |
| FPopupMethodReply | Popups can manifest in a NEW OS WINDOW or via an OVERLAY in an existing window. | ||
| TOptional< bool > | OnQueryShowFocus
(
const EFocusCause InFocusCause |
Called to determine if we should render the focus brush. | |
| void | Called when a tooltip displayed from this widget is being closed | ||
| FReply | OnTouchEnded
(
const FGeometry& MyGeometry, |
Called when a touchpad touch is ended (finger lifted) | |
| FReply | OnTouchFirstMove
(
const FGeometry& MyGeometry, |
Called when a touchpad touch first moves after TouchStarted | |
| FReply | OnTouchForceChanged
(
const FGeometry& MyGeometry, |
Called when a touchpad touch force changes | |
| FReply | OnTouchGesture
(
const FGeometry& MyGeometry, |
TOUCH and GESTURES Called when the user performs a gesture on trackpad. This event is bubbled. | |
| FReply | OnTouchMoved
(
const FGeometry& MyGeometry, |
Called when a touchpad touch is moved (finger moved) | |
| FReply | OnTouchStarted
(
const FGeometry& MyGeometry, |
Called when a touchpad touch is started (finger down) | |
| TSharedPtr< FPopupLayer > | OnVisualizePopup
(
const TSharedRef< SWidget >& PopupContent |
Visualize a new pop-up if possible. | |
| bool | OnVisualizeTooltip
(
const TSharedPtr< SWidget >& TooltipContent |
Called when Slate wants to visualize tooltip. | |
| int32 | Paint
(
const FPaintArgs& Args, |
GENERAL EVENTS Called to tell a widget to paint itself (and it's children). | |
| void | Prepass_ChildLoop
(
float InLayoutScaleMultiplier, |
||
| TSharedRef< FActiveTimerHandle > | RegisterActiveTimer
(
float TickPeriod, |
Registers an "active timer" delegate that will execute at some regular interval. | |
| int32 | RemoveMetaData
(
const TSharedRef< MetaDataType >& RemoveMe |
Remove metadata to this widget. | |
| bool | SetAttribute
(
TAttribute< TargetValueType >& TargetValue, |
Performs the attribute assignment and invalidates the widget minimally based on what actually changed. | |
| void | SetCanTick
(
bool bInCanTick |
||
| void | SetClipping
(
EWidgetClipping InClipping |
Sets the clipping to bounds rules for this widget. | |
| void | SetCullingBoundsExtension
(
const FMargin& InCullingBoundsExtension |
Sets an additional culling padding that is added to a widget to give more leeway when culling widgets. | |
| void | SetCursor
(
const TAttribute< TOptional< EMouseCursor::Type > >& InCursor |
Set the cursor that should appear when this widget is hovered | |
| void | SetDebugInfo
(
const ANSICHAR* InType, |
Used by Slate to set the runtime debug info about this widget. | |
| void | SetEnabled
(
TAttribute< bool > InEnabledState |
Sets the enabled state of this widget | |
| void | SetFlowDirectionPreference
(
EFlowDirectionPreference InFlowDirectionPreference |
Sets how content should flow in this panel, based on the current culture. | |
| void | SetHover
(
TAttribute< bool > InHovered |
Set the hover state. | |
| void | SetOnMouseButtonDown
(
FPointerEventHandler EventHandler |
See OnMouseButtonDown event | |
| void | SetOnMouseButtonUp
(
FPointerEventHandler EventHandler |
See OnMouseButtonUp event | |
| void | SetOnMouseDoubleClick
(
FPointerEventHandler EventHandler |
See OnMouseDoubleClick event | |
| void | SetOnMouseEnter
(
FNoReplyPointerEventHandler EventHandler |
See OnMouseEnter event | |
| void | SetOnMouseLeave
(
FSimpleNoReplyPointerEventHandler EventHandler |
See OnMouseLeave event | |
| void | SetOnMouseMove
(
FPointerEventHandler EventHandler |
See OnMouseMove event | |
| void | SetPixelSnapping
(
EWidgetPixelSnapping InPixelSnappingMethod |
Sets the pixel snapping method for this widget. | |
| void | SetRenderOpacity
(
float InRenderOpacity |
||
| void | SetRenderTransform
(
TAttribute< TOptional< FSlateRenderTransform > > InTransform |
||
| void | SetRenderTransformPivot
(
TAttribute< FVector2D > InTransformPivot |
||
| void | |||
| void | SetToolTip
(
const TAttribute< TSharedPtr< IToolTip > >& InToolTip |
Set the tool tip that should appear when this widget is hovered. | |
| void | SetToolTipText
(
const FText& InToolTipText |
Set the tool tip that should appear when this widget is hovered. | |
| void | SetToolTipText
(
const TAttribute< FText >& ToolTipText |
Set the tool tip that should appear when this widget is hovered. | |
| void | SetVisibility
(
TAttribute< EVisibility > InVisibility |
||
| void | SetVolatilePrepass
(
bool bVolatile |
||
| bool | ShouldBeEnabled
(
bool InParentEnabled |
Determines if this widget should be enabled. | |
| bool | |||
| void | SlatePrepass () |
DEPRECATED version of SlatePrepass that assumes no scaling beyond AppScale | |
| void | SlatePrepass
(
float InLayoutScaleMultiplier |
Descends to leaf-most widgets in the hierarchy and gathers desired sizes on the way up. | |
| const FSlateWidgetClassData & | |||
| bool | Checks to see if this widget supports keyboard focus. Override this in derived classes. | ||
| void | SWidgetConstruct
(
const FSlateBaseNamedArgs& Args |
Construct a SWidget based on initial parameters. | |
| void | Ticks this widget with Geometry. | ||
| FString | ToString () |
||
| TOptional< FVirtualPointerPosition > | TranslateMouseCoordinateForCustomHitTestChild
(
const SWidget& ChildWidget, |
||
| void | UnRegisterActiveTimer
(
const TSharedRef< FActiveTimerHandle >& ActiveTimerHandle |
Unregisters an active timer handle. | |
| bool | ValidatePathToChild
(
SWidget* InChild |
Overridden from FSlateControlledConstruction
| Type | Name | Description | |
|---|---|---|---|
| const FSlateWidgetClassData & |
Classes
| Type | Name | Description | |
|---|---|---|---|
| TSlateAttribute | A SlateAttribute that is member variable of a SWidget. | ||
| TSlateAttribute< FText, InInvalidationReasonValue > | |||
| TSlateAttributeRef | A Reference to a TSlateAttribute. | ||
| TSlateAttributeRef< FText, InInvalidationReasonValue > | |||
| TSlateManagedAttribute | A SlateAttribute that is NOT a member variable of a SWidget. | ||
| TSlateManagedAttribute< FText, InInvalidationReasonValue > |
Typedefs
| Name | Description |
|---|---|
| PrivateParentType | |
| PrivateThisType | |
| Super | |
| ThisClass |