UE4
Topic Author
Posts: 62
Joined: 29 Dec 2017, 06:32

Question about RaiseEvent(Args) and sample UserControl

05 Mar 2018, 02:46

In UserControl sample, I find the RaiseEvent(Args) is used to send event to MainWIndow, I want to know, if I have more than one event to send, how can I do it

MyControl.Xaml
<UserControl>
 	<TouchButton TouchDown="EventA" TouchUp="EventB"/>
</UserControl>
class
{
virtual bool ConnectEvent() override;
HandleEventA()
{
	RaiseEvent()// A
}
HandleEventB()
{
	RaiseEvent() //B
}

static const RoutedEvent* EventA;
static const RoutedEvent* EventB;
}
MainWindow.Xaml
<MainWindow> 
	<MyControl EventA="HandleEventA" EventB="HandleEventB"/>
</MainWindow>
class
{
virtual bool ConnectEvent() override;
HandleEventA();
HandleEventB();
}
 
UE4
Topic Author
Posts: 62
Joined: 29 Dec 2017, 06:32

Re: Question about RaiseEVent(Args) and sample UserControl

05 Mar 2018, 07:48

In UserControl, it is defined a raw Event:
//your sample
RoutedEvent_<Noesis::RoutedPropertyChangedEventHandler<int>::Handler> ValueChanged()
{
	return RoutedEvent_<RoutedPropertyChangedEventHandler<int>::Handler>(this, ValueChangedEvent);
}
And I defined a custom event:

Noesis::UIElement::RoutedEvent_<Noesis::TouchEventHandler> GameGUI::TouchButton::TouchButtonDown()
{
	//right way?
	return RoutedEvent_<TouchEventHandler>(this, TouchButtonDownEvent);
}


 
User avatar
hcpizzi
Site Admin
Posts: 316
Joined: 09 Feb 2012, 12:40

Re: Question about RaiseEVent(Args) and sample UserControl

06 Mar 2018, 17:10

Hi,

As you figured out, if you want to create multiple custom events, you need multiple
static const Noesis::RoutedEvent*
members in your class. This RoutedEvent is passed as part of the RoutedEventArgs when you call RaiseEvent.

As for the type of the event arguments, it depends. The code you've added is valid, but the TouchEventArgs contain information, such as a position and the id of the finger it refers to, that may not be required in your case. You can use RoutedEventArgs (and RoutedEventHandler) if you have no other information to send other than that the event happened. But feel free to use TouchEventArgs if that's what you need.
 
UE4
Topic Author
Posts: 62
Joined: 29 Dec 2017, 06:32

Re: Question about RaiseEVent(Args) and sample UserControl

07 Mar 2018, 07:48

Hi,

As you figured out, if you want to create multiple custom events, you need multiple
static const Noesis::RoutedEvent*
members in your class. This RoutedEvent is passed as part of the RoutedEventArgs when you call RaiseEvent.

As for the type of the event arguments, it depends. The code you've added is valid, but the TouchEventArgs contain information, such as a position and the id of the finger it refers to, that may not be required in your case. You can use RoutedEventArgs (and RoutedEventHandler) if you have no other information to send other than that the event happened. But feel free to use TouchEventArgs if that's what you need.
thanks, got it.

Who is online

Users browsing this forum: No registered users and 68 guests