[Slate] STileView, .OnGenerateTile - how to get it working ?

So I have this simple widget:

	ChildSlot
		.VAlign(VAlign_Fill)
		.HAlign(HAlign_Fill)
		[
			SNew(SOverlay)
			+SOverlay::Slot()
			.HAlign(EHorizontalAlignment::HAlign_Center)
			.VAlign(EVerticalAlignment::VAlign_Top)
			[
				SNew(STileView)
				.ListItemsSource(&PowersList)
				.OnGenerateTile(&SRPGPowerInventoryWidget::SOnGenerateWidgetForList)
			]

		];

TSharedRef SRPGPowerInventoryWidget::SOnGenerateWidgetForList( URPGPowerBase* InItem )
{
	return SNew(STextBlock).Text( FString(InItem->Description) );
}

I have based it on this comment found in SListView.h

 * A trivial use case appear below:
 *
 *   Given: TArray< FString* > Items;
 *
 *   SNew( SListView< FString* > )
 *     .ItemHeight(24)
 *     .ListItemsSource( &Items )
 *     .OnGenerateRow( SListView< TSharedPtr >::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 OnGenerateWidgetForList( FString* InItem )
 * {
 *     return SNew(STextBlock).Text( (*InItem) )
 * }
 *
 */

Since there is no function MakeOnGenerateWidget, I have skipped this part.

And during compilation I get this error:

1>D:\Unreal\RPG\Source\RPG\HUD\Widgets\SRPGPowerInventoryWidget.cpp(37): error C2664: 'STileView::FArguments &STileView::FArguments::OnGenerateTile(const TBaseDelegate_RetVal_TwoParams &)' : cannot convert parameter 1 from 'TSharedRef (__cdecl SRPGPowerInventoryWidget::* )(URPGPowerBase *)' to 'const TBaseDelegate_RetVal_TwoParams &'
1>          with
1>          [
1>              ItemType=URPGPowerBase *,
1>              RetValType=TSharedRef,
1>              Param1Type=URPGPowerBase *,
1>              Param2Type=const TSharedRef &
1>          ]
1>          and
1>          [
1>              ObjectType=ITableRow
1>          ]
1>          and
1>          [
1>              RetValType=TSharedRef,
1>              Param1Type=URPGPowerBase *,
1>              Param2Type=const TSharedRef &
1>          ]
1>          Reason: cannot convert from 'TSharedRef (__cdecl SRPGPowerInventoryWidget::* )(URPGPowerBase *)' to 'const TBaseDelegate_RetVal_TwoParams'
1>          with
1>          [
1>              ObjectType=ITableRow
1>          ]
1>          and
1>          [
1>              RetValType=TSharedRef,
1>              Param1Type=URPGPowerBase *,
1>              Param2Type=const TSharedRef &
1>          ]

Well, I don’t have experience using STileView, but for SListView and STreeView I used this:

TSharedRef SSearchBoxWidget::CreateRowWidget(TSharedPtr Item, const TSharedRef< STableViewBase >& OwnerTable)
{
	TSharedRef< SListThing > ReturnRow = SNew(SListThing, OwnerTable)
		.ItemThingName(Item)
		.OnDragDetected(this,&SSearchBoxWidget::OnDragDetected);

	return ReturnRow;
}

The default OnGenerate passes those two parameters to it’s delegate by default I think.

I also used a custom slate widget that extends STableRow, it just holds a textbox though. I couldn’t get the ListView to accept a plain STextBlock, although the examples say it’s possible.

Thanks for help I got it working!

TSharedRef SRPGPowerInventoryWidget::SOnGenerateWidgetForList(URPGPowerBase* Item, const TSharedRef< STableViewBase >& OwnerTable)
{
	 TSharedRef< STableRow > ReturnRow = SNew(STableRow  , OwnerTable)
       .Content()
	   [
			SNew(STextBlock)
			.Text(FString(Item->Description))	   
	   ];
 
    return ReturnRow;
}

I don’t know if you tried it, but it is possible that you missed .Content() and that’s why you couldn’t get it working directly.

Now Only thing I’m missing is real-time updates of new incoming data and drag&drop…

I totally missed .Content() :stuck_out_tongue: That’ll come in handy next time, thanks :slight_smile: