UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ListView.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
9#include "Input/DragAndDrop.h"
10
11#include "ListView.generated.h"
12
21
27
28/*
29 * A virtualized list that allows up to thousands of items to be displayed.
30 *
31 * An important distinction to keep in mind here is "Item" vs. "Entry"
32 * The list itself is based on a list of n items, but only creates as many entry widgets as can fit on screen.
33 * For example, a scrolling ListView of 200 items with 5 currently visible will only have created 5 entry widgets.
34 *
35 * To make a widget usable as an entry in a ListView, it must inherit from the IUserObjectListEntry interface.
36 */
37UCLASS(meta = (EntryInterface = "/Script/UMG.UserObjectListEntry"), MinimalAPI)
39{
41
43
44public:
46
47 UMG_API virtual void ReleaseSlateResources(bool bReleaseChildren) override;
48 UMG_API virtual void PostLoad() override;
49
51 template <typename ItemObjectT, typename AllocatorType = FDefaultAllocator>
53 {
54 ClearListItems();
55 ListItems.Reserve(InListItems.Num());
56 for (const ItemObjectT ListItem : InListItems)
57 {
58 if (ListItem != nullptr)
59 {
60 ListItems.Add(ListItem);
61 }
62 }
63
64 OnItemsChanged(ListItems, TArray<UObject*>());
65
66 RequestRefresh();
67 }
68
69 ESelectionMode::Type GetSelectionMode() const { return SelectionMode; }
71
72 template <typename RowWidgetT = UUserWidget>
74 {
75 return Item ? ITypedUMGListView<UObject*>::GetEntryWidgetFromItem<RowWidgetT>(const_cast<UObject*>(Item)) : nullptr;
76 }
77 UMG_API void SetSelectedItem(const UObject* Item);
78
80 template <typename ObjectT = UObject>
85
90 UFUNCTION(BlueprintCallable, Category = ListView)
91 const TArray<UObject*>& GetListItems() const { return ListItems; }
92
94 UFUNCTION(BlueprintCallable, Category = ListView)
95 UMG_API void AddItem(UObject* Item);
96
98 UFUNCTION(BlueprintCallable, Category = ListView)
99 UMG_API void RemoveItem(UObject* Item);
100
102 UFUNCTION(BlueprintCallable, Category = ListView)
103 UMG_API UObject* GetItemAt(int32 Index) const;
104
106 UFUNCTION(BlueprintCallable, Category = ListView)
107 UMG_API int32 GetNumItems() const;
108
110 UFUNCTION(BlueprintCallable, Category = ListView)
111 UMG_API int32 GetIndexForItem(const UObject* Item) const;
112
114 UFUNCTION(BlueprintCallable, Category = ListView)
115 UMG_API void ClearListItems();
116
118 UFUNCTION(BlueprintCallable, Category = ListView)
119 UMG_API void SetSelectionMode(TEnumAsByte<ESelectionMode::Type> SelectionMode);
120
121 /* Sets ScrollIntoViewAlignment which allows to stick the selected item to either side or center */
122 UFUNCTION(BlueprintCallable, Category = ListView)
123 UMG_API void SetScrollIntoViewAlignment (EScrollIntoViewAlignment NewScrollIntoViewAlignment);
124
126 UFUNCTION(Category = ListView)
127 UMG_API void SetScrollBarPadding(const FMargin& InScrollBarPadding);
128
130 UFUNCTION(BlueprintCallable, Category = ListView)
131 UMG_API bool IsRefreshPending() const;
132
134 UFUNCTION(BlueprintCallable, Category = ListView)
135 UMG_API void ScrollIndexIntoView(int32 Index);
136
138 UFUNCTION(BlueprintCallable, Category = ListView)
139 UMG_API void SetSelectedIndex(int32 Index);
140
142 UFUNCTION(BlueprintCallable, Category = ListView)
143 UMG_API void NavigateToIndex(int32 Index);
144
145 UMG_API virtual UObject* GetListObjectFromEntry(UUserWidget& EntryWidget) override;
146
147protected:
148 UMG_API virtual void OnItemsChanged(const TArray<UObject*>& AddedItems, const TArray<UObject*>& RemovedItems);
149
150 UFUNCTION()
151 UMG_API void OnListItemEndPlayed(AActor* Item, EEndPlayReason::Type EndPlayReason);
152
153 UFUNCTION()
154 UMG_API void OnListItemOuterEndPlayed(AActor* ItemOuter, EEndPlayReason::Type EndPlayReason);
155
156 UMG_API virtual TSharedRef<STableViewBase> RebuildListWidget() override;
157 UMG_API virtual void HandleListEntryHovered(UUserWidget& EntryWidget) override;
158 UMG_API virtual void HandleListEntryUnhovered(UUserWidget& EntryWidget) override;
159 // Drag Drop handlers
160 UMG_API virtual UDragDropOperation* HandleListEntryDragDetected(const FGeometry& MyGeometry, const FPointerEvent& PointerEvent, UUserWidget& EntryWidget) override;
161 UMG_API virtual TOptional<EItemDropZone> HandleListEntryCanAcceptDrop(const FDragDropEvent& DropEvent, EItemDropZone DropZone, UUserWidget& EntryWidget) override;
162 UMG_API virtual FReply HandleListEntryAcceptDrop(const FDragDropEvent& DropEvent, EItemDropZone DropZone, UUserWidget& EntryWidget) override;
163 UMG_API virtual void HandleListEntryDragEnter(const FDragDropEvent& DropEvent, UUserWidget& EntryWidget) override;
164 UMG_API virtual void HandleListEntryDragLeave(const FDragDropEvent& DropEvent, UUserWidget& EntryWidget) override;
165 UMG_API virtual void HandleListEntryDragCancelled(const FDragDropEvent& DropEvent) override;
166 //End Drag Drop
167
168#if WITH_EDITOR
169 UMG_API virtual void OnRefreshDesignerItems() override;
170#endif
171
172 UMG_API virtual UUserWidget& OnGenerateEntryWidgetInternal(UObject* Item, TSubclassOf<UUserWidget> DesiredEntryClass, const TSharedRef<STableViewBase>& OwnerTable) override;
173 UMG_API virtual FMargin GetDesiredEntryPadding(UObject* Item) const override;
174
175 UMG_API virtual void OnItemClickedInternal(UObject* Item) override;
176 UMG_API virtual void OnItemDoubleClickedInternal(UObject* Item) override;
177 UMG_API virtual void OnSelectionChangedInternal(UObject* FirstSelectedItem) override;
178 UMG_API virtual void OnItemScrolledIntoViewInternal(UObject* Item, UUserWidget& EntryWidget) override;
179 UMG_API virtual void OnListViewScrolledInternal(float ItemOffset, float DistanceRemaining) override;
180 UMG_API virtual void OnListViewFinishedScrollingInternal() override;
181 UMG_API virtual bool OnIsSelectableOrNavigableInternal(UObject* FirstSelectedItem) override;
182
183 UMG_API void HandleOnEntryInitializedInternal(UObject* Item, const TSharedRef<ITableRow>& TableRow);
184
186 template <template<typename> class ListViewT = SListView>
188 {
189 FListViewConstructArgs Args;
190 Args.bAllowFocus = bIsFocusable;
191 Args.SelectionMode = SelectionMode;
192 Args.bClearSelectionOnClick = bClearSelectionOnClick;
193 Args.ConsumeMouseWheel = ConsumeMouseWheel;
194 Args.bReturnFocusToSelection = bReturnFocusToSelection;
195 Args.bClearScrollVelocityOnSelection = bClearScrollVelocityOnSelection;
196 Args.Orientation = Orientation;
197 Args.ListViewStyle = &WidgetStyle;
198 Args.ScrollBarStyle = &ScrollBarStyle;
199 Args.ShadowBoxStyle = &ShadowBrushStyle;
200 Args.bEnableShadowBoxStyle = bEnableShadowBrush;
201 Args.ScrollBarPadding = ScrollBarPadding;
202 Args.ScrollIntoViewAlignment = ScrollIntoViewAlignment;
203 MyListView = ITypedUMGListView<UObject*>::ConstructListView<ListViewT>(this, ListItems, Args);
204
206
207 return StaticCastSharedRef<ListViewT<UObject*>>(MyListView.ToSharedRef());
208 }
209
210protected:
211 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ListView, meta = (DisplayName = "Style"))
212 FTableViewStyle WidgetStyle;
213
214 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ListView)
215 FScrollBarStyle ScrollBarStyle;
216
217 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Style", meta=( DisplayName="Enable Shadow Brush Style" ))
218 bool bEnableShadowBrush = false;
219
220 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, Category="Style", meta=( DisplayName="Shadow Brush Style", EditCondition = bEnableShadowBrush, EditConditionHides ))
221 FScrollBoxStyle ShadowBrushStyle;
222
228 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ListView)
230
231 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ListView)
233
234 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ListView)
236
237 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ListView)
238 bool bClearSelectionOnClick = false;
239
240 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ListView)
241 bool bIsFocusable = true;
242
243 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ListView)
244 bool bClearScrollVelocityOnSelection = true;
245
246 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ListView)
247 bool bReturnFocusToSelection = false;
248
250 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Scrolling)
252
255
257
258#if WITH_EDITORONLY_DATA
263 UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "EntrySpacing has been deprecated. Please use HorizontalEntrySpacing and VerticalEntrySpacing."), BlueprintReadOnly, BlueprintGetter = "GetHorizontalEntrySpacing", Category = ListView, meta = (ClampMin = 0))
264 float EntrySpacing = 0.f;
265#endif // WITH_EDITOR
266
267private:
268 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, Category = ListView, meta = (ClampMin = 0, AllowPrivateAccess = "true"))
269 float HorizontalEntrySpacing = 0.f;
270
271 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, Category = ListView, meta = (ClampMin = 0, AllowPrivateAccess = "true"))
272 float VerticalEntrySpacing = 0.f;
273
274 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, Category = ListView, meta = (AllowPrivateAccess = "true", DisplayAfter="ScrollBarStyle"))
275 FMargin ScrollBarPadding;
276
277
278public:
280 UFUNCTION(BlueprintCallable, Category = ListView)
281 float GetHorizontalEntrySpacing() const { return HorizontalEntrySpacing; }
282
284 UFUNCTION(BlueprintCallable, Category = ListView)
285 float GetVerticalEntrySpacing() const { return VerticalEntrySpacing; }
286
288 UFUNCTION(Category = ListView)
289 FMargin GetScrollBarPadding() const { return ScrollBarPadding; }
290
292 UMG_API void SetVerticalEntrySpacing(float InVerticalEntrySpacing);
293
295 UMG_API void SetHorizontalEntrySpacing(float InHorizontalEntrySpacing);
296
298 UMG_API void SetShadowBrushStyle(const FScrollBoxStyle& NewWidgetStyle);
299
301 UMG_API const FScrollBoxStyle& GetShadowBrushStyle() const;
302
303protected:
304 UE_DEPRECATED(5.6, "InitHorizontalEntrySpacing is deprecated, please use SetHorizontalEntrySpacing instead.")
305 UMG_API void InitHorizontalEntrySpacing(float InHorizontalEntrySpacing);
306
307 UE_DEPRECATED(5.6, "InitVerticalEntrySpacing is deprecated, please use SetVerticalEntrySpacing instead.")
308 UMG_API void InitVerticalEntrySpacing(float InVerticalEntrySpacing);
309
310private:
311 // BP exposure of ITypedUMGListView API
312
314 UFUNCTION(BlueprintCallable, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "Set Selected Item"))
315 UMG_API void BP_SetSelectedItem(UObject* Item);
316
318 UFUNCTION(BlueprintCallable, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "Set Item Selection"))
319 UMG_API void BP_SetItemSelection(UObject* Item, bool bSelected);
320
322 UFUNCTION(BlueprintCallable, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "Clear Selection"))
323 UMG_API void BP_ClearSelection();
324
326 UFUNCTION(BlueprintCallable, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "Get Num Items Selected"))
327 UMG_API int32 BP_GetNumItemsSelected() const;
328
330 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "GetSelectedItems"))
331 UMG_API bool BP_GetSelectedItems(TArray<UObject*>& Items) const;
332
334 UFUNCTION(BlueprintCallable, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "Is Item Visible"))
335 UMG_API bool BP_IsItemVisible(UObject* Item) const;
336
338 UFUNCTION(BlueprintCallable, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "Navigate To Item"))
339 UMG_API void BP_NavigateToItem(UObject* Item);
340
342 UFUNCTION(BlueprintCallable, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "Scroll Item Into View"))
343 UMG_API void BP_ScrollItemIntoView(UObject* Item);
344
346 UFUNCTION(BlueprintCallable, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "Cancel Scroll Into View"))
347 UMG_API void BP_CancelScrollIntoView();
348
350 UFUNCTION(BlueprintCallable, Category = ListView, meta = (AllowPrivateAccess = true, DisplayName = "Set List Items", ViewmodelBlueprintWidgetExtension = "EntryViewModel"))
351 UMG_API void BP_SetListItems(const TArray<UObject*>& InListItems);
352
354 UFUNCTION(BlueprintCallable, Category = ListView, meta = (DisplayName = "Get Selected Item", AllowPrivateAccess = true))
355 UMG_API UObject* BP_GetSelectedItem() const;
356
357private:
359 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Entry Initialized"))
360 FOnListEntryInitializedDynamic BP_OnEntryInitialized;
361
362 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Clicked"))
363 FSimpleListItemEventDynamic BP_OnItemClicked;
364
365 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Double Clicked"))
366 FSimpleListItemEventDynamic BP_OnItemDoubleClicked;
367
368 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Drag Detected"))
369 FOnItemGeometryMulticastDynamic BP_OnItemDragDetected;
370
371 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Drag Enter"))
372 FOnItemDragDropMulticastDynamic BP_OnItemDragEnter;
373
374 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Drag Leave"))
375 FOnItemDragDropMulticastDynamic BP_OnItemDragLeave;
376
377 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Accept Drop"))
378 FOnItemZoneMulticastDynamic BP_OnItemAcceptDrop;
379
380 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Drag Cancelled"))
381 FOnItemDragCancelledDynamic BP_OnItemDragCancelled;
382
383 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On List View Dragging State Changed"))
384 FOnListViewDraggingStateChangedDynamic BP_OnListViewDraggingStateChanged;
385
386 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Is Hovered Changed"))
387 FOnItemIsHoveredChangedDynamic BP_OnItemIsHoveredChanged;
388
389 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Selection Changed"))
390 FOnListItemSelectionChangedDynamic BP_OnItemSelectionChanged;
391
392 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On Item Scrolled Into View"))
393 FOnListItemScrolledIntoViewDynamic BP_OnItemScrolledIntoView;
394
395 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On List View Scrolled"))
396 FOnListViewScrolledDynamic BP_OnListViewScrolled;
397
398 UPROPERTY(BlueprintAssignable, Category = Events, meta = (DisplayName = "On List View Finished Scrolling"))
399 FOnListViewFinishedScrollingDynamic BP_OnListViewFinishedScrolling;
400
401 UPROPERTY(BlueprintReadWrite, Category = Events, meta = (AllowPrivateAccess, DisplayName = "On Is Item Selectable Or Navigable"))
402 FOnIsItemSelectableOrNavigableDynamic BP_OnIsItemSelectableOrNavigable;
403};
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param1Name, Param2Type, Param2Name)
Definition DelegateCombinations.h:62
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE(DelegateName)
Definition DelegateCombinations.h:38
#define DECLARE_DYNAMIC_DELEGATE_RetVal_OneParam(ReturnValueType, DelegateName, Param1Type, Param1Name)
Definition DelegateCombinations.h:55
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(DelegateName, Param1Type, Param1Name, Param2Type, Param2Name, Param3Type, Param3Name)
Definition DelegateCombinations.h:71
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type, Param1Name)
Definition DelegateCombinations.h:53
EUMGItemDropZone
Definition DragDropOperation.h:21
return true
Definition ExternalRpcRegistry.cpp:601
#define IMPLEMENT_TYPED_UMG_LIST(ItemType, ListPropertyName)
Definition ListViewBase.h:887
@ Num
Definition MetalRHIPrivate.h:234
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UCLASS(...)
Definition ObjectMacros.h:776
EItemDropZone
Definition STableRow.h:59
EScrollIntoViewAlignment
Definition STableViewBase.h:60
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
EOrientation
Definition SlateEnums.h:261
EConsumeMouseWheel
Definition SlateTypes.h:26
Definition Actor.h:257
Definition DragAndDrop.h:141
Definition UObjectGlobals.h:1292
Definition UnrealType.h:3087
Definition Reply.h:24
Definition ListViewBase.h:40
Definition SListView.h:66
Definition STableViewBase.h:110
Definition Array.h:670
Definition EnumAsByte.h:22
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition SubclassOf.h:30
Definition DragDropOperation.h:55
Definition ListViewBase.h:546
Definition ListView.h:39
TSharedRef< ListViewT< UObject * > > ConstructListView()
Definition ListView.h:187
RowWidgetT * GetEntryWidgetFromItem(const UObject *Item) const
Definition ListView.h:73
EOrientation GetOrientation() const
Definition ListView.h:70
ObjectT * GetSelectedItem() const
Definition ListView.h:81
void SetListItems(const TArray< ItemObjectT, AllocatorType > &InListItems)
Definition ListView.h:52
ESelectionMode::Type GetSelectionMode() const
Definition ListView.h:69
UMG_API void HandleOnEntryInitializedInternal(UObject *Item, const TSharedRef< ITableRow > &TableRow)
Definition ListView.cpp:154
Definition Object.h:95
Definition UserWidget.h:284
Definition EngineTypes.h:3429
Definition ITypedTableView.h:14
Type
Definition ITypedTableView.h:16
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition Geometry.h:40
Definition Margin.h:17
Definition Events.h:695
Definition SlateTypes.h:932
Definition SlateTypes.h:2023
Definition SlateTypes.h:1606
Definition ObjectPtr.h:488
Definition Optional.h:131