Page 1 of 1

Get event by name

Posted: 17 Apr 2015, 01:27
by Rick
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.

Re: Get event by name

Posted: 17 Apr 2015, 01:46
by jsantos
We use symbols internally to avoid comparing strings. A symbol is internally an integer. You can create a symbol from string easily:
NsSymbol sym(eventName);
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.

Re: Get event by name

Posted: 17 Apr 2015, 02:06
by Rick
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();

Re: Get event by name

Posted: 17 Apr 2015, 02:08
by jsantos
Yes, thanks for the feedback.