- add argument for EventHandler.Find() which allows searching by parent class (default false)
This commit is contained in:
parent
0e621e2f30
commit
abdacad8d3
2 changed files with 11 additions and 1 deletions
|
|
@ -1699,9 +1699,14 @@ DEFINE_ACTION_FUNCTION(DEventHandler, Find)
|
|||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(t, DStaticEventHandler);
|
||||
PARAM_BOOL(subclass);
|
||||
for (DStaticEventHandler* handler = currentVMLevel->localEventManager->FirstEventHandler; handler; handler = handler->next)
|
||||
{
|
||||
if (handler->GetClass() == t) // check precise class
|
||||
ACTION_RETURN_OBJECT(handler);
|
||||
else if (subclass && handler->IsKindOf(t));
|
||||
ACTION_RETURN_OBJECT(handler);
|
||||
}
|
||||
ACTION_RETURN_OBJECT(nullptr);
|
||||
}
|
||||
|
||||
|
|
@ -1710,9 +1715,14 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, Find)
|
|||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(t, DStaticEventHandler);
|
||||
PARAM_BOOL(subclass);
|
||||
for (DStaticEventHandler* handler = staticEventManager.FirstEventHandler; handler; handler = handler->next)
|
||||
{
|
||||
if (handler->GetClass() == t) // check precise class
|
||||
ACTION_RETURN_OBJECT(handler);
|
||||
else if (subclass && handler->IsKindOf(t));
|
||||
ACTION_RETURN_OBJECT(handler);
|
||||
}
|
||||
ACTION_RETURN_OBJECT(nullptr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ class StaticEventHandler : Object native play version("2.4")
|
|||
{
|
||||
// static event handlers CAN register other static event handlers.
|
||||
// unlike EventHandler.Create that will not create them.
|
||||
clearscope static native StaticEventHandler Find(Class<StaticEventHandler> type); // just for convenience. who knows.
|
||||
clearscope static native StaticEventHandler Find(Class<StaticEventHandler> type, bool subclass = false); // just for convenience. who knows.
|
||||
|
||||
// these are called when the handler gets registered or unregistered
|
||||
// you can set Order/IsUiProcessor here.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue