x

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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Slate UI TextBlock, Text_Lambda to update the Text?

I have a Slate widget that I create like this:

   void SetUpWidget()
     {
     
         FText SlateHUDText = FText::FromString("This is the first text");
     
     
         FLevelEditorModule& LevelEditor = FModuleManager::GetModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
         TSharedPtr<ILevelViewport> LViewport = LevelEditor.GetFirstActiveViewport();
         
     
         TSharedRef<SWidget> NewWidget = SNew(SOverlay)
             + SOverlay::Slot()
             .VAlign(VAlign_Top)
             .HAlign(HAlign_Center)
             [
                 SNew(STextBlock)
                 .ColorAndOpacity(FLinearColor::White)
             .Font(FSlateFontInfo("Veranda", 16))
             .Text(TestHUDText)
             //.Text_Lambda() // HOW TO?
             ];
     
         LViewport->AddOverlayWidget(NewWidget);
     
     }


I have another function that updates a string variable on Tick. What I would like to do is BIND the string variable to the TSharedRef TextBlock, so that it updates every time the variable does. Is this done with the Text_Lambda attribute? Or is there another way?

Thanks!

Product Version: UE 4.20
Tags:
more ▼

asked Oct 05 '18 at 02:16 PM in C++ Programming

avatar image

antithing
292 20 31 51

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

1 answer: sort voted first

Ah, solved it.

//.h

 FString displayStr = "this string";


//from above code

 .Text_Lambda([this]()->FText {return FText::FromString(displayStr); })


more ▼

answered Oct 05 '18 at 02:22 PM

avatar image

antithing
292 20 31 51

avatar image Shadowriver Oct 05 '18 at 02:27 PM

Lamda is new C++ feature from C++11 so not all C++ tutorials teach that https://en.cppreference.com/w/cpp/language/lambda

(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