Callback inside function

Hello,

I have Login Controller which you can see on screenshot, that Login Controller handles Login logic, then I have UI Widget which handles UI and calls Login function in Login Controller (I want to have separated UI and logic), problem is that I don’t know how to create Custom Event for that callback function in Call function, I tried even Macro and it doesn’t work either.

Why I need to have it in function? Because I want to be able to return something into Widget UI, like success, error, so then I can display Error message for it.

1 Like

CreateBinding

My Products

1 Like

interesting, when I added return node to the new function I cannot callback it anymore nad get error

image

Press Create a matching function.

CreateBinding

I did, then I added return node to that function and stopped working.

You could create an event dispatcher and call it when you want to send a callback. Then bind your widget event to the dispatcher.

Controller:

Widget:

ah interesting but I wanted that callback function inside Login function in Login Controller,

anyway, now Im trying to do it using Blueprint Interfaces,

I created BPI_Login like this:

image

Then I added that interface to Widget UI and added “listener” like this:

image

and Im trying to send message from Login Controller to all Blueprints which has that interface (because I dont have ref for that Widget UI in Login Controller) like this:

But I dont get printed “sent message”, I get only “login response” and “completed”

EDIT: my bad I had “Get all Actors” I changed it to “Get all Widgets” like this and it works now:

But I dont know if it is correct way to communicate between UI and “backend logic”

To send messages to widgets, you have to call GetAllWidgetsWithInterface.

Yes, I just edited my post :slight_smile:

1 Like

I prefer an event dispatcher, as I’ve suggested above.

  1. You call the function Login:

  1. Then you execute your Login function:

  1. Then send a callback to the widget with the event dispatcher:

  1. And catch it in the widget:

Okay, thank you very much for this idea too :slight_smile: