# Possible to check if Event Dispatcher has events bound?

**URL:** <https://forums.unrealengine.com/t/possible-to-check-if-event-dispatcher-has-events-bound/121662>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [January 28, 2019, 12:48am UTC](https://forums.unrealengine.com/t/possible-to-check-if-event-dispatcher-has-events-bound/121662 "2019-01-28T00:48:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kresjah](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kresjah](https://forums.unrealengine.com/u/Kresjah)\
**Post date:** [January 28, 2019, 12:48am UTC](https://forums.unrealengine.com/t/possible-to-check-if-event-dispatcher-has-events-bound/121662/1 "2019-01-28T00:48:38Z")

</div>

Pretty much what the title of the topic says. Let’s say I have an event dispatcher named “PerformAction”, is there a way for me in blueprint to check if there are events bound to PerformAction and return this as a boolean? Alternatively return the number of events bound to is (in which case I can get the boolean myself from a more-than-zero check)? As a bonus, is there some way to get the list of events bound to it?

---

<div class="post-metadata">

**Author:** ![SenseiHaketon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SenseiHaketon](https://forums.unrealengine.com/u/SenseiHaketon)\
**Post date:** [February 6, 2019, 2:18pm UTC](https://forums.unrealengine.com/t/possible-to-check-if-event-dispatcher-has-events-bound/121662/2 "2019-02-06T14:18:54Z")

</div>

I don’t think there is a way to do this. That probably doesn’t even work in C++.

---

<div class="post-metadata">

**Author:** ![mordentral](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mordentral](https://forums.unrealengine.com/u/mordentral)\
**Post date:** [February 6, 2019, 3:17pm UTC](https://forums.unrealengine.com/t/possible-to-check-if-event-dispatcher-has-events-bound/121662/3 "2019-02-06T15:17:55Z")

</div>

> [@SenseiHaketon](#):
>
> I don’t think there is a way to do this. That probably doesn’t even work in C++.

Sure you can, EventDelegates have multiple useful functions for these things (not in BP though).

> **[TMulticastScriptDelegate](https://docs.unrealengine.com/5.3/en-US/API/Runtime/Core/UObject/TMulticastScriptDelegate/)**
>
> Script multi-cast delegate base class

You can check IsBound() for if it is bound at all, get a list of the bound objects (can obtain a count from that) and check if it already Contains() your function delegate.

---

<div class="post-metadata">

**Author:** ![SenseiHaketon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SenseiHaketon](https://forums.unrealengine.com/u/SenseiHaketon)\
**Post date:** [February 6, 2019, 3:36pm UTC](https://forums.unrealengine.com/t/possible-to-check-if-event-dispatcher-has-events-bound/121662/4 "2019-02-06T15:36:58Z")

</div>

> [@mordentral](#):
>
> Sure you can, EventDelegates have multiple useful functions for these things (not in BP though).
> 
> [TMulticastScriptDelegate | Unreal Engine 5.2 Documentation](http://api.unrealengine.com/INT/API/Runtime/Core/UObject/TMulticastScriptDelegate/)
> 
> You can check IsBound() for if it is bound at all, get a list of the bound objects (can obtain a count from that) and check if it already Contains() your function delegate.

Nice, learned something new! 🙂

---

<div class="post-metadata">

**Author:** ![NilsonLima](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NilsonLima](https://forums.unrealengine.com/u/NilsonLima)\
**Post date:** [February 6, 2019, 8:13pm UTC](https://forums.unrealengine.com/t/possible-to-check-if-event-dispatcher-has-events-bound/121662/5 "2019-02-06T20:13:01Z")

</div>

Yeah nice to check some threads just for the sake of learning new things.

---

<div class="post-metadata">

**Author:** ![Kresjah](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kresjah](https://forums.unrealengine.com/u/Kresjah)\
**Post date:** [February 11, 2019, 5:30am UTC](https://forums.unrealengine.com/t/possible-to-check-if-event-dispatcher-has-events-bound/121662/6 "2019-02-11T05:30:43Z")

</div>

Thanks for the replies. Shame it isn’t possible to access from blueprints, but at least I learned something new and know that if I transition to C++ I have those options available.

---

<div class="post-metadata">

**Author:** ![RC-1290](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rc-1290/32/261500_2.png) [@RC-1290](https://forums.unrealengine.com/u/RC-1290)\
**Post date:** [September 2, 2022, 3:49pm UTC](https://forums.unrealengine.com/t/possible-to-check-if-event-dispatcher-has-events-bound/121662/7 "2022-09-02T15:49:49Z")

</div>

I needed to see what was bound to an event, and this was one of the threads that helped me figure it out, along with [Getting a list of events from blueprint and calling them in C++](https://forums.unrealengine.com/t/getting-a-list-of-events-from-blueprint-and-calling-them-in-c/470252)

It is possible to create a blueprint library function in C++, that helps you get this information, through Unreal’s reflection system.

It looks like events created through the unreal editor, are of type FMulticastScriptDelegate (at least that’s how ScriptCore.cpp seems to call the events). But you can use the TFieldIterator with FMulticastDelegateProperty to get a list of the events on an object.

The blogpost on Reflection in Unreal( [Unreal Property System (Reflection) - Unreal Engine](https://www.unrealengine.com/en-US/blog/unreal-property-system-reflection) ) only mentions UProperty, and things like UENUM, UCLASS, USTRUCT, and UFUNCTION, but you can also use subclasses to filter, apparently. The fact that UProperty was refactored to FProperty makes things extra confusing, but FMulticastDelegateProperty is valid, so yay.

header file:

```auto
UFUNCTION( BlueprintCallable, Category = "Event" )
static TArray<FString> GetEventNames( UObject* Target);

```

implementation file:

```auto
TArray<FString> UEventInfo::GetEventNames( UObject* Target )
{
	UClass* classReference = Target->GetClass();
	TArray<FString> eventNames;

	for (TFieldIterator<FMulticastDelegateProperty> propertyIterator( classReference, EFieldIteratorFlags::ExcludeSuper ); propertyIterator; ++propertyIterator)
	{
		FMulticastDelegateProperty* Property = *propertyIterator;
		eventNames.Add( propertyIterator->GetName() );
	}
		
	return eventNames;
}

```

In that example I’m excluding inherited events, but you can just remove that flag to get all of them.

To get a list of the bound objects, you need a reference to a specific instance of the event, rather than a class wide property. ScriptCore.cpp mentioned above has a call to GetMulticastDelegate, but that requires an address, and it appears that you can’t just use a reference to the UObject. The thread [Correct way to get the value of a Property?](https://forums.unrealengine.com/t/correct-way-to-get-the-value-of-a-property/551897) points in the right direction, by calling ContainerPtrToValuePtr first.

That lets you get the reference to the MulticastScriptDelegate, which lets you call GetAllObjects().  
Header:

```auto
UFUNCTION( BlueprintCallable, Category = "Event" )
static TArray<UObject*> GetObjectsReferencedByEvent( UObject* Target, FString EventName );

```

```auto
TArray<UObject*> UEventInfo::GetObjectsReferencedByEvent( UObject* Target, FString EventName )
{
	TArray<UObject*> referencedObjects;
	UClass* classReference = Target->GetClass();

	for (TFieldIterator<FMulticastDelegateProperty> propertyIterator( classReference, EFieldIteratorFlags::ExcludeSuper ); propertyIterator; ++propertyIterator)
	{
		FMulticastDelegateProperty* Property = *propertyIterator;
		if (propertyIterator->GetName() == EventName) {
			void* ValueAddress = Property->ContainerPtrToValuePtr< void >( Target );
			const FMulticastScriptDelegate* DelegateAddr = Property->GetMulticastDelegate( ValueAddress );

			referencedObjects.Append( DelegateAddr->GetAllObjects());
		}
	}

	return referencedObjects;
}

```

GetAllObjects says:

> For advanced uses only – you should never need call this function in normal circumstances.

but I’d argue that in normal circumstances, the list of objects referenced by a blueprint event should already exist, because how else are you going to precisely debug whether events are correctly subscribed to or unsubscribed from. So when it doesn’t exist, we have little choice but calling GetAllObjects ourselves.

Anyway, I hope that helps someone. (It might at least help me in the future)
