Exposing UE delegates and events to DataEventTrigger
Posted: 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:
The view model:
And the actual event call from the xaml code behind
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...
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:
Code: Select all
<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>
...
Code: Select all
public class ViewModel_ContentItemBase
{
...
public event System.EventHandler RequestFocus;
public void InvokeFocusRequest()
{
RequestFocus?.Invoke(this, System.EventArgs.Empty);
}
}
Code: Select all
void OnLoaded(object _sender, EventArgs _e)
{
ViewModel.ListItems[2].InvokeFocusRequest();
}
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...