- DominikRuta
- Posts: 3
- Joined:
Handling UIElement events in UE5
Hello, I have a simple question. Is there a way how to listen on UIElement events and handle them in UE5 c++ class while still getting event arguments like this?
Registering the callback in XAML would look something like this:
I know how to listen on them like this using Behaviors, but in some cases, I need context of that view object.
Thank you
Code: Select all
void UMyUnrealView::OnMouseWheel(BaseComponent* component, const Noesis::MouseWheelEventArgs& e)
{
// Do some stuff
return;
}
Code: Select all
<Canvas MouseWheel="OnMouseWheel">
...
</Canvas>
Thank you
Re: Handling UIElement events in UE5
If I understand it correctly, you want to be able to receive the event arguments in a handler function in your ViewModel, which is an UObject derived class. Am I right?
In that case, that is not possible at the moment. If all you need is to know the source of the event, that could be done using behaviors.
In that case, that is not possible at the moment. If all you need is to know the source of the event, that could be done using behaviors.
-
sfernandez
Site Admin
- Posts: 3093
- Joined:
Re: Handling UIElement events in UE5
It's already been reported the possibility to receive event arguments as the command parameter in the InvokeCommandAction, but it's still not implemented: #2723
If you only need to receive the element that sent the event (although it is rare that in a ViewModel you need to know about a specific UI element of the view), you can pass it as the command parameter:
If you only need to receive the element that sent the event (although it is rare that in a ViewModel you need to know about a specific UI element of the view), you can pass it as the command parameter:
Code: Select all
<Canvas x:Name="canvas" Background="Transparent">
<b:Interaction.Triggers>
<b:EventTrigger EventName="MouseWheel">
<b:InvokeCommandAction Command="{Binding SomeCommand}" CommandParameter="{Binding ElementName=canvas}"/>
</b:EventTrigger EventName="MouseWheel">
</b:Interaction.Triggers>
</Canvas>
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests