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:

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

Did you tried to bind pointer of that property?

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?

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

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.

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

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

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.