SListView

Copyright Epic Games, Inc. All Rights Reserved.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Slate

Header

/Engine/Source/Runtime/Slate/Public/Widgets/Views/SListView.h

Include

#include "Widgets/Views/SListView.h"

Syntax

template<typename ItemType>
class SListView :
    public STableViewBase,
    private TListTypeTraits< ItemType >::SerializerType,
    public ITypedTableView< ItemType >

Remarks

A ListView widget observes an array of data items and creates visual representations of these items. ListView relies on the property that holding a reference to a value ensures its existence. In other words, neither SListView<FString> nor SListView<FString*> are valid, while SListView< TSharedPtr<FString> > and SListView< UObject* > are valid.

A trivial use case appear below:

Given: TArray< TSharedPtr<FString> > Items;

SNew( SListView< TSharedPtr<FString> > ) .ItemHeight(24) .ListItemsSource( &Items ) .OnGenerateRow( SListView< TSharedPtr<FString> >::MakeOnGenerateWidget( this, &MyClass::OnGenerateRowForList ) )

In the example we make all our widgets be 24 screen units tall. The ListView will create widgets based on data items in the Items TArray. When the ListView needs to generate an item, it will do so using the OnGenerateWidgetForList method.

A sample implementation of OnGenerateWidgetForList would simply return a TextBlock with the corresponding text:

TSharedRef<ITableRow> OnGenerateWidgetForList( TSharedPtr<FString> InItem, const TSharedRef<STableViewBase>& OwnerTable ) { return SNew(STextBlock).Text( (*InItem) ) }

Variables

Name Description

Protected variable

bool

 

bClearSelectionOnClick

If true, the selection will be cleared if the user clicks in empty space (not on an item)

Protected variable

bool

 

bHandleDirectionalNavigation

Should directional nav be supported

Protected variable

bool

 

bHandleGamepadEvents

Should gamepad nav be supported

Protected variable

bool

 

bNavigateOnScrollIntoView

If true, the item currently slated to be scrolled into view will also be navigated to after being scrolled in

Protected variable

bool

 

bReturnFocusToSelection

If true, the focus will be returned to the last selected object in a list when navigated to.

Protected variable

TItemSet

 

HighlightedItems

A set of which items should be highlighted

Protected variable

TAttribute< boo...

 

IsFocusable

True when the list view supports keyboard focus

Protected variable

const TArray< I...

 

ItemsSource

Pointer to the array of data items that we are observing

Protected variable

NullableItemTyp...

 

ItemToNotifyWhenInView

When set, the list will notify this item when it has been scrolled into view

Protected variable

NullableItemTyp...

 

ItemToScrollIntoView

When not null, the list will try to scroll to this item on tick.

Protected variable

float

 

NavigationScrollOffset

The additional scroll offset (in items) to show when navigating to rows at the edge of the visible area (i.e. how much of the following item(s) to show)

Protected variable

FOnMouseButtonC...

 

OnClick

Called when the user clicks on an element int he list view with the left mouse button

Protected variable

FOnMouseButtonD...

 

OnDoubleClick

Called when the user double-clicks on an element in the list view with the left mouse button

Protected variable

FOnTableViewBad...

 

OnEnteredBadState

Invoked when the tree enters a bad state.

Protected variable

FOnEntryInitial...

 

OnEntryInitialized

Invoked after initializing an entry being generated, before it may be added to the actual widget hierarchy.

Protected variable

FOnGenerateRow

 

OnGenerateRow

Delegate to be invoked when the list needs to generate a new widget from a data item.

Protected variable

FIsSelectableOr...

 

OnIsSelectableOrNavigable

Delegate to invoke to see if we can navigate or select item.

Protected variable

FOnItemScrolled...

 

OnItemScrolledIntoView

Delegate to be invoked when an item has come into view after it was requested to come into view.

Protected variable

FOnItemToString...

 

OnItemToString_Debug

Assign this to get more diagnostics from the list view.

Protected variable

FOnWidgetToBeRe...

 

OnRowReleased

Protected variable

FOnSelectionCha...

 

OnSelectionChanged

Delegate to invoke when selection changes.

Protected variable

NullableItemTyp...

 

RangeSelectionStart

The item which was last manipulated; used as a start for shift-click selection

Protected variable

TItemSet

 

SelectedItems

A set of selected data items

Protected variable

NullableItemTyp...

 

SelectorItem

The item to manipulate selection for

Protected variable

uint32

 

UserRequestingScrollIntoView

The user index requesting the item to be scrolled into view.

Protected variable

FWidgetGenerato...

 

WidgetGenerator

A widget generator component

Constructors

Name Description

Public function

SListView

(
    ETableViewMode::Type InListMode
)

Functions

Name Description

Public function Virtual

void

 

AddReferencedObjects

(
    FReferenceCollector& Collector
)

Lists and Trees serialize items that they observe because they rely on the property that holding a reference means it will not be garbage collected.

Public function

void

 

CancelScrollIntoView()

Cancels a previous request to scroll an item into view (cancels navigation requests as well).

Public function

void

 

ClearHighlightedItems()

Empty the highlighted item set.

Public function

void

 

ClearSelection()

Empty the selection set.

Public function

void

 

Construct

(
    const typename SListView< ItemType ...
)

Construct this widget

Public function Virtual

TSharedRef< ...

 

GenerateNewWidget

(
    ItemType InItem
)

Given an data item, generate a widget corresponding to it.

Public function

float

 

GenerateWidgetForItem

(
    const ItemType& CurItem,
    int32 ItemIndex,
    int32 StartIndex,
    float LayoutScaleMultiplier
)

Protected function Static

FOnItemToStr...

 

GetDefaultDebugDelegate()

Public function

FVector2D

 

GetMaxRowSizeForColumn

(
    const FName& ColumnId,
    EOrientation ColumnOrientation
)

Will determine the max row size for the specified column id

Public function Const

int32

 

GetNumItemsSelected()

Gets the number of selected items.

Public function Const

int32

 

GetSelectedItems

(
    TArray< ItemType >& SelectedItemAr...
)

Public function Const

bool

 

IsItemSelected

(
    const ItemType& InItem
)

Test if the current item is selected.

Public function Const

bool

 

IsItemVisible

(
    ItemType Item
)

Checks whether the specified item is currently visible in the list view.

Public function Const

const ItemTy...

 

ItemFromWidget

(
    const ITableRow* WidgetToFind
)

Given a Widget, find the corresponding data item.

Protected function Virtual

void

 

NavigationSelect

(
    const ItemType& InItemToSelect,
    const FInputEvent& InInputEvent
)

Selects the specified item and scrolls it into view. If shift is held, it will be a range select.

Protected function

ItemType

 

Private_FindNextSelectableOrNavigable

(
    const ItemType& InItemToSelect
)

Public function

void

 

Private_OnEntryInitialized

(
    ItemType TheItem,
    const TSharedRef< ITableRow >& Tab...
)

A low-level interface for use various widgets generated by ItemsWidgets(Lists, Trees, etc).

Public function

void

 

RequestNavigateToItem

(
    ItemType Item,
    const uint32 UserIndex
)

Navigate to a specific item, scrolling it into view if needed.

Public function

void

 

RequestScrollIntoView

(
    ItemType ItemToView,
    const uint32 UserIndex
)

Scroll an item into view. If the item is not found, fails silently.

Public function

void

 

SetItemHighlighted

(
    const ItemType& TheItem,
    bool bHighlighted
)

Set the highlighted state of an item.

Public function

void

 

SetItemSelection

(
    const ItemType& InItem,
    bool bSelected,
    ESelectInfo::Type SelectInfo
)

Set the selection state of an item.

Public function

void

 

SetItemSelection

(
    const TArray< ItemType >& InItems,
    bool bSelected,
    ESelectInfo::Type SelectInfo
)

Set the selection state of multiple items.

Public function

void

 

SetListItemsSource

(
    const TArray< ItemType >& InListIt...
)

Establishes a wholly new list of items being observed by the list.

Public function

void

 

SetOnEntryInitialized

(
    const FOnEntryInitialized& Delegat...
)

Sets the OnEntryInitializer delegate.

Public function

void

 

SetSelection

(
    ItemType SoleSelectedItem,
    ESelectInfo::Type SelectInfo
)

Set the currently selected Item.

Public function

void

 

SetSelectionMode

(
    const TAttribute< ESelectionMode::T...
)

Set the current selection mode of the list.

Overridden from STableViewBase

Name Description

Public function Virtual Const

int32

 

GetNumItemsBeingObserved()

Protected function Virtual

void

 

NotifyItemScrolledIntoView()

Called when an item has entered the visible geometry to check to see if the ItemScrolledIntoView delegate should be fired.

Public function Virtual

void

 

RebuildList()

Completely wipe existing widgets and fully regenerate them on next tick.

Public function Virtual

FReGenerateR...

 

ReGenerateItems

(
    const FGeometry& MyGeometry
)

Update generate Widgets for Items as needed and clean up any Widgets that are no longer needed.

Protected function Virtual

float

 

ScrollBy

(
    const FGeometry& MyGeometry,
    float ScrollByAmount,
    EAllowOverscroll InAllowOverscroll
)

Scroll the list view by some number of screen units.

Protected function Virtual

EScrollIntoV...

 

ScrollIntoView

(
    const FGeometry& ListViewGeometry
)

If there is a pending request to scroll an item into view, do so.

Public function Virtual

void

 

UpdateSelectionSet()

Remove any items that are no longer in the list from the selection set.

Overridden from SWidget

Name Description

Public function Virtual

TSharedRef< ...

 

CreateAccessibleWidget()

Public function Virtual Const

TOptional< F...

 

GetDefaultAccessibleText

(
    EAccessibleType AccessibleType
)

Assign AccessibleText with a default value that can be used when AccessibleBehavior is set to Auto or Custom.

Public function Virtual

FReply

 

OnKeyDown

(
    const FGeometry& MyGeometry,
    const FKeyEvent& InKeyEvent
)

Called after a key is pressed when this widget has focus (this event bubbles if not handled)

Public function Virtual

FReply

 

OnMouseButtonDown

(
    const FGeometry& MyGeometry,
    const FPointerEvent& MouseEvent
)

MOUSE INPUT The system calls this method to notify the widget that a mouse button was pressed within it.

Public function Virtual

FReply

 

OnMouseButtonUp

(
    const FGeometry& MyGeometry,
    const FPointerEvent& MouseEvent
)

The system calls this method to notify the widget that a mouse button was release within it.

Public function Virtual

FNavigationR...

 

OnNavigation

(
    const FGeometry& MyGeometry,
    const FNavigationEvent& InNavigati...
)

Called when navigation is requested e.g. Left Joystick, Direction Pad, Arrow Keys can generate navigation events.

Public function Virtual Const

bool

 

SupportsKeyboardFocus()

Checks to see if this widget supports keyboard focus. Override this in derived classes.

Overridden from ITypedTableView

Name Description

Public function Virtual

TSharedRef< ...

 

AsWidget()

Public function Virtual Const

TArray< Item...

 

GetSelectedItems()

Returns a list of selected item indices, or an empty array if nothing is selected

Public function Virtual Const

ETableViewMo...

 

GetTableViewMode()

Public function Virtual

void

 

Private_ClearHighlightedItems()

Empty the set of highlighted items.

Public function Virtual

void

 

Private_ClearSelection()

Empty the selection set.

Public function Virtual Const

bool

 

Private_DoesItemHaveChildren

(
    int32 ItemIndexInList
)

Public function Virtual Const

int32

 

Private_GetNestingDepth

(
    int32 ItemIndexInList
)

Public function Virtual Const

int32

 

Private_GetNumSelectedItems()

Public function Virtual Const

EOrientation

 

Private_GetOrientation()

Public function Virtual Const

ESelectionMo...

 

Private_GetSelectionMode()

Public function Virtual Const

const TBitAr...

 

Private_GetWiresNeededByDepth

(
    int32 ItemIndexInList
)

Public function Virtual Const

bool

 

Private_HasSelectorFocus

(
    const ItemType& TheItem
)

Test if the item passed in has selector focus.

Public function Virtual Const

bool

 

Private_IsItemExpanded

(
    const ItemType& TheItem
)

Public function Virtual Const

bool

 

Private_IsItemHighlighted

(
    const ItemType& TheItem
)

Test if the current item should be highlighted. This is separate from hover highlights.

Public function Virtual Const

bool

 

Private_IsItemSelectableOrNavigable

(
    const ItemType& TheItem
)

Test if the current item can be selected or navigated to.

Public function Virtual Const

bool

 

Private_IsItemSelected

(
    const ItemType& TheItem
)

Test if the current item is selected.

Public function Virtual Const

bool

 

Private_IsLastChild

(
    int32 ItemIndexInList
)

Public function Virtual Const

bool

 

Private_IsPendingRefresh()

Is the list pending a refresh?

Public function Virtual Const

const ItemTy...

 

Private_ItemFromWidget

(
    const ITableRow* TheWidget
)

Given a Widget, find the corresponding data item.

Public function Virtual

void

 

Private_OnExpanderArrowShiftClicked

(
    ItemType TheItem,
    bool bShouldBeExpanded
)

Called when the expander arrow for the given item is shift+clicked.

Public function Virtual

bool

 

Private_OnItemClicked

(
    ItemType TheItem
)

Called when the item is clicked, and returns whether or not the event was handled

Public function Virtual

bool

 

Private_OnItemDoubleClicked

(
    ItemType TheItem
)

Called when the item is double-clicked, and returns whether or not the event was handled

Public function Virtual

void

 

Private_OnItemRightClicked

(
    ItemType TheItem,
    const FPointerEvent& MouseEvent
)

Called when the item is right-clicked when not right mouse scrolling

Public function Virtual

void

 

Private_SelectRangeFromCurrentTo

(
    ItemType SelectorItem
)

Select a range of items from the current RangeSelectionStart to the SelectorItem Does not cause an OnSelectionChanged()!

Public function Virtual

void

 

Private_SetItemExpansion

(
    ItemType TheItem,
    bool bShouldBeExpanded
)

Set whether some data item is expanded or not.

Public function Virtual

void

 

Private_SetItemHighlighted

(
    ItemType TheItem,
    bool bShouldBeHighlighted
)

Enable a soft highlight on the element.

Public function Virtual

void

 

Private_SetItemSelection

(
    ItemType TheItem,
    bool bShouldBeSelected,
    bool bWasUserDirected
)

Set the selection state of an item.

Public function Virtual

void

 

Private_SignalSelectionChanged

(
    ESelectInfo::Type SelectInfo
)

Notify the ItemsWidget that we changed its selection.

Public function Virtual Const

bool

 

Private_UsesSelectorFocus()

Returns whether the table view uses selector focus.

Public function Virtual Const

TSharedPtr< ...

 

WidgetFromItem

(
    const ItemType& InItem
)

Find a widget for this item if it has already been constructed.

Classes

Name

Description

Public struct

FArguments

Protected class

FSlateAccessibleListView

An accessible implementation for SListView to be exposed to platform accessibility APIs.

Typedefs

Deprecated Functions

Name Description

Public function

void

 

RequestScrollIntoView

(
    ItemType ItemToView,
    const uint32 UserIndex,
    const bool NavigateOnScrollIntoView
)

RequestScrollIntoView no longer takes parameter bNavigateOnScrollIntoView. Call RequestNavigateToItem instead of RequestScrollIntoView if navigation is required.

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