RealDocs

AActor::OnClicked

property Engine Blueprint Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: UPROPERTYBlueprintAssignable

Description

Multicast delegate fired when the left mouse button is clicked while the mouse is over this actor and click events are enabled in the player controller.

Caveats & Gotchas

  • Click events must be enabled on the PlayerController (`bEnableClickEvents = true`) for this delegate to fire. It does not fire by default.
  • This delegate only fires for the actor directly under the cursor — it does not bubble up through an attachment hierarchy. If you have a child actor, bind on each actor individually.
  • Works with mouse input only. For touch input, use OnInputTouchBegin instead.

Signature

UPROPERTY(BlueprintAssignable, Category="Input|Mouse Input")
FActorOnClickedSignature OnClicked;

Example

Bind a click handler in BeginPlay C++
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	OnClicked.AddDynamic(this, &AMyActor::HandleClicked);
}

void AMyActor::HandleClicked(AActor* TouchedActor, FKey ButtonPressed)
{
	UE_LOG(LogTemp, Log, TEXT("%s clicked with %s"), *GetName(), *ButtonPressed.ToString());
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.