How To Fire Mouse-Hover Callback

Hello, I have an Actor class that has a callback function that is suppose to fire when the cursor begins hovering over the mesh but it never actually fires. What am I doing wrong?

In constructor:

MyMeshComponent->OnBeginCursorOver.AddDynamic(this, &AMyActor::MyOnBeginMouseOver);

Callback Function:

void AMyActor::MyOnBeginMouseOver(UPrimitiveComponent* TouchedComponent)
{
	GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Green, TEXT("Mouse Over"));
}

This is a first person shooter so the reticle is always in the center of the screen but I’m not sure if the mouse cursor is there too as it is hidden… that might have something to do with it.

“This is a first person shooter so the reticle is always in the center of the screen but I’m not sure if the mouse cursor is there too as it is hidden… that might have something to do with it.”

Yes this is it

use the ShowMouseCursor option in the PC class to figure out where the cursor actually use

//override this to return true all the time, or whenever you want
virtual bool ShouldShowMouseCursor() const;

Use GetMousePosition() to… well… you know :slight_smile:

Rama

PS: you could set this directly, but probably less useful in longer term

/** Whether the mouse cursor should be displayed. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=MouseInterface)
uint32 bShowMouseCursor:1;

I was having trouble getting a mouse event to trigger as well. Apparently the function needs to be marked as UFUNCTION(), like this:

 UFUNCTION() void MyOnBeginMouseOver(UPrimitiveComponent* TouchedComponent);

This may be obvious to some people, but it certainly took me a while.

Thanks for replying to this. I would have never guessed…