Hello, the topic says the main problem. These events get fired only when I have my mouse over my static mesh and when these functions are implemented the OnClicked function doesn’t get fired anymore… I have tried to do this with both c++ and blueprint. I can get the OnClicked event working correctly. I have set the bEnableMouseOverEvents to true in my controller and it is the right controller.
Here is my .h code:
UFUNCTION(Category = Default)
void Numpad1OnClick(UPrimitiveComponent* pComponent, FKey inKey);
UFUNCTION(Category = Default)
void Numpad1OnHover(class UPrimitiveComponent * pComponent);
UFUNCTION(Category = Default)
void Numpad1OnLeave(class UPrimitiveComponent* pComponent);
And here is necessary parts in the cpp
Getting the controller and doing the settings:
APlayerController* controller = UGameplayStatics::GetPlayerController(this->GetWorld(), 0);
controller->bShowMouseCursor = true;
controller->bEnableClickEvents = true;
controller->bEnableMouseOverEvents = true;
Binding functions to events:
numpadKey1->OnClicked.AddDynamic(this, &AAccessPanel::Numpad1OnClick);
numpadKey1->OnBeginCursorOver.AddDynamic(this, &AAccessPanel::Numpad1OnHover);
numpadKey1->OnEndCursorOver.AddDynamic(this, &AAccessPanel::Numpad1OnLeave);
And the functions themselves:
void AAccessPanel::Numpad1OnClick(UPrimitiveComponent * pComponent, FKey inKey)
{
UE_LOG(LogTemp, Warning, TEXT("Number 1 CLICKed!"));
}
void AAccessPanel::Numpad1OnHover(class UPrimitiveComponent * pComponent)
{
UE_LOG(LogTemp, Warning, TEXT("Number 1 mouse OVER!"));
}
void AAccessPanel::Numpad1OnLeave(class UPrimitiveComponent * pComponent)
{
UE_LOG(LogTemp, Warning, TEXT("Number 1 mouse LEFT!"));
}
I have tried changing the collision types of my static mesh but it doesn’t solve this and I think that CursorOver and EndCursorOver should work if OnClicked works? Anything more I can try or is this a bug?