vmaurer
Topic Author
Posts: 14
Joined: 21 Jul 2022, 17:44

Exposing UE delegates and events to DataEventTrigger

18 Apr 2023, 17:08

Hey guys,

I followed the documentation to create a DataEventTrigger calling SetFocusAction on a button, whenever an event is raised on the viewmodel. In the blend project all is working as intended.
The xaml snippet:
<Style x:Key="ButtonStyle_Concept" TargetType="{x:Type Button}">
		...
		<Setter Property="noesis:StyleInteraction.Triggers">
			<Setter.Value>
				<noesis:StyleTriggerCollection>
					...
					<noesis:DataEventTrigger Source="{Binding}" EventName="RequestFocus">
						<noesis:SetFocusAction />
					</noesis:DataEventTrigger>
				</noesis:StyleTriggerCollection>
			</Setter.Value>
		</Setter>
...
The view model:
public class ViewModel_ContentItemBase
{
	...
	public event System.EventHandler RequestFocus;

	public void InvokeFocusRequest()
	{
		RequestFocus?.Invoke(this, System.EventArgs.Empty);
	}
}
And the actual event call from the xaml code behind
void OnLoaded(object _sender, EventArgs _e)
{
	ViewModel.ListItems[2].InvokeFocusRequest();
}
If I run it in blend, the focus is set on the third button as expected.
But then I went on recreating the viewmodel in our UE5 c++ project and can't figure out what type to use for "RequestEvent". I tried declaring various UE event types (DECLARE_EVENT(...) and such), but it seems they're not supported by the Noesis wrapper and using Noesis::EventHandler wouldn't even compile.

Any idea?

EDIT:
I spent some time studying and debugging the NoesisTypeClass source files to confirm that there's indeed no way to expose delegates or events to Noesis. Plus, I found out that when a DataEventTrigger gets registered it looks for an entry in the mEvents array. But never does the NoesisTypeClass code ever modify that array.
Maybe I'm still missing something...
 
User avatar
hcpizzi
Site Admin
Posts: 304
Joined: 09 Feb 2012, 12:40

Re: Exposing UE delegates and events to DataEventTrigger

20 Apr 2023, 12:44

Hello,

As you figured out, at the moment there's no support for it, but I'm looking into it. Could you please create a ticket for it?

I'm still looking into the issue, but the more likely scenario would be to expose multi cast delegate properties as events, as those can be declared both in C++ and in Blueprint.
 
vmaurer
Topic Author
Posts: 14
Joined: 21 Jul 2022, 17:44

Re: Exposing UE delegates and events to DataEventTrigger

20 Apr 2023, 13:41

Hi, I just submitted a ticket: #2575
Let me know, if you need more specific info.

I agree, multi cast delegates would probably be the best option for this. And if it simplifies the implementation, I think parameterless delegates would be ok for now.
 
vmaurer
Topic Author
Posts: 14
Joined: 21 Jul 2022, 17:44

Re: Exposing UE delegates and events to DataEventTrigger

05 May 2023, 14:18

We integrated the patch linked with the bug ticket and it's working as expected. Thanks!
 
User avatar
jsantos
Site Admin
Posts: 3747
Joined: 20 Jan 2012, 17:18
Contact:

Re: Exposing UE delegates and events to DataEventTrigger

08 May 2023, 11:39

Thanks for the feedback! This will be officially available in 3.2.1

Who is online

Users browsing this forum: Bing [Bot] and 1 guest