Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Lambda as slate delegate

Is it possible to use a lambda as a slate delegate for generating items in a SListView?


 SNew(SListView<TSharedRef<FString> >)
     .OnGenerateRow([](TSharedRef<FString> string)->TSharedRef < ITableRow > {return SNew(STextBlock).Text((*string)); })

I'm guessing that if it is possible I'd have to wrap this somehow as an actual delegate, as I get an error about being unable to convert from the lambda to a RetVal_TwoParams delegate. Is this the case, and if so how would I go about doing so?

Product Version: Not Selected
more ▼

asked Jun 23 '14 at 12:42 AM in C++ Programming

avatar image

1.5k 55 36 73

avatar image MorskoyZmey Jun 23 '14 at 05:37 AM

Does RetVal_TwoParams mean that your lambda should accept two arguments?

avatar image twiddle Jun 23 '14 at 05:47 AM

According to the comments in SListView.h:

 * A sample implementation of OnGenerateWidgetForList would simply return a TextBlock with the corresponding text:
  * TSharedRef<ITableRow> OnGenerateWidgetForList( FString* InItem )
  * {
  *     return SNew(STextBlock).Text( (*InItem) )
  * }

Bearing this in mind, I shouldn't need two parameters in the lambda, because the sample delegate function provided there doesn't take two.

avatar image Jamie Dale STAFF Jun 23 '14 at 09:35 AM

That comment is wrong (perhaps old), I've updated it.

FOnGenerateRow needs two parameters, your item, and the owner table. To update the example you used above, this would be:

  TSharedRef<ITableRow> OnGenerateWidgetForList( FString* InItem, const TSharedRef<STableViewBase>& OwnerTable )
      return SNew(STextBlock).Text( (*InItem) )
avatar image twiddle Jun 23 '14 at 09:40 AM

Thanks for the clarification, Jamie. Will give it a shot and see how things go :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You should be able to use a lambda providing they don't capture anything. Our delegates don't really support lambdas, but they do support static function pointers, and a stateless lambda will convert to a function pointer.

more ▼

answered Jun 23 '14 at 09:38 AM

avatar image

Jamie Dale STAFF
7.5k 177 67 305

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question