Get event by name
I'm trying to get an event by it's name and I was pointed to the following code:
const TypeClass* type = button3->GetClassType();
const RoutedEvent* clickEvent = Noesis::Gui::FindRoutedEventRecursive(type, clickEventName);
However, FindRuitedEventRecursive's 2nd parameter isn't a string event name, it's some NsSymbol which isn't making sense to me when I look at it's description.
const TypeClass* type = button3->GetClassType();
const RoutedEvent* clickEvent = Noesis::Gui::FindRoutedEventRecursive(type, clickEventName);
However, FindRuitedEventRecursive's 2nd parameter isn't a string event name, it's some NsSymbol which isn't making sense to me when I look at it's description.
Re: Get event by name
We use symbols internally to avoid comparing strings. A symbol is internally an integer. You can create a symbol from string easily:
Having said that, that function should be getting a string instead of a symbol. We should avoid exposing those details in the public API whenever possible. Will be fixed.
Code: Select all
NsSymbol sym(eventName);
Re: Get event by name
Thanks. While you are at it you may want to change this too in event handlers.
NsSymbol eventName = e.routedEvent->GetName();
Otherwise we have to do:
string eventName = NsSymbol(e.routedEvent->GetName()).GetStr();
NsSymbol eventName = e.routedEvent->GetName();
Otherwise we have to do:
string eventName = NsSymbol(e.routedEvent->GetName()).GetStr();
Re: Get event by name
Yes, thanks for the feedback.
Who is online
Users browsing this forum: No registered users and 2 guests