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"

Dynamic text in custom K2 Node

Hi there!

I'm creating a bunch of new blueprint nodes for a plugin I'm developping. Some of these nodes need to have a text box at the bottom, which I managed to do as you can see in this image: alt text

Now, the idea is that these nodes have some details in the detail panel when you select them, like this text box you see in the picture. I would like to bind the text in the SRichTextBox of the node to this Text field in the details panel. Like, when the user commits a new text, it automatically updates the text in the box.

Do you think it's possible? How would you do it?

Thanks a lot for every answer!

From a - not so - Crafty Weazel

Product Version: UE 4.21
more ▼

asked Dec 14 '18 at 01:08 AM in C++ Programming

avatar image

62 5 7 12

avatar image Shadowriver Dec 14 '18 at 04:37 AM

Did you tried to bind pointer of that property?

avatar image CraftyWeazel Dec 14 '18 at 07:24 AM

I only need to bind a pointer? I don't think it's possible, I can't convert from UProperty to TAttribute or something. Maybe just a FText pointer?

avatar image Firefly74 Dec 14 '18 at 09:45 AM

i think nodes have the "PostEditChangeProperty" methods called in that situation too. Did you allready check that way ?

avatar image CraftyWeazel Dec 15 '18 at 10:27 AM

I've already overriden this method, indeed, but for another thing. How should I act on the Slate-side of my node from the PostEditChangeProperty in my K2Node? I think it's only the Slate object which holds a pointer to the K2Node, and not the contrary.

avatar image Firefly74 Dec 15 '18 at 11:16 AM

If you put a breakpoint on the method and edit the box, is the method triggered ? For the slate thing, you could make a binding method for the text of slate object Ex: https://answers.unrealengine.com/questions/359240/properly-binding-function-to-slate-text.html

avatar image CraftyWeazel Dec 15 '18 at 01:04 PM

Great, that worked pretty well :) Thank you. I will make a proper answer with code references and mark it as answered.

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

1 answer: sort voted first

Thanks to Firefly74's comments and the link he gave me, I was able to do it.

So here is my final code for those who wonder:

Inside my Slate widget, I declare the text value this way. It's bound to a function in the slate widget which is called "GetTextFromNode()":

 TAttribute<FText> Value = TAttribute<FText>::Create(TAttribute<FText>::FGetter::CreateRaw(this, &SGraphDialogNode::GetTextFromNode));

This function is implemented as follows:

 FText SGraphDialogNode::GetTextFromNode() const
     UBPNode_DialogBase* DialogNode = dynamic_cast<UBPNode_DialogBase*>(GraphNode);
     if (DialogNode)
         return DialogNode->TryGetText();
     return LOCTEXT("NoText", "");

And in the UBP_DialogBase node, I am returning a FText depending on the node properties. I will do all text parsing there in order to make full use of RichText widget.

more ▼

answered Dec 16 '18 at 12:24 PM

avatar image

62 5 7 12

(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