I have the following code:
this->capsuleComponent->OnClicked.AddUniqueDynamic(this, &AInventoryItem::ItemOnClicked);
This method gets fired when left click occurs over the top of an actor but not when right click.
void AInventoryItem::ItemOnClicked(UPrimitiveComponent* touchedComponent, FKey buttonPressed)
{
// This does not fire when right click is pressed.
}
What am i missing?
This is what i was aiming for:
void AInventoryItem::ItemOnClicked(UPrimitiveComponent* touchedComponent, FKey buttonPressed)
{
AMainPlayerController* mainPlayerController = (AMainPlayerController*)this->GetWorld()->GetFirstPlayerController();
if (buttonPressed == EKeys::LeftMouseButton)
{
// Run default actions
UE_LOG(LogTemp, Warning, TEXT("AInventoryItem::ItemOnClicked was called. left mouse button was pressed"));
}
else if (buttonPressed == EKeys::RightMouseButton)
{
// Bring up action menu
mainPlayerController->ToggleActionMenu();
UE_LOG(LogTemp, Warning, TEXT("AInventoryItem::ItemOnClicked was called. right mouse button was pressed"));
}
}
EDIT:
I’ve just seen the comment:
/** Event called when the left mouse button is released while the mouse is over this component click events are enabled in the player controller */
UPROPERTY(BlueprintAssignable, Category="Input|Mouse Input")
FComponentOnReleasedSignature OnReleased;
so what is the method that accepts right click?..