Download

UMG: Firing OnMouseMove while MouseDown

I have a HUD and arrows on all sides of it to move the camera when the player hovers over them. This works just fine. However when I have the mouse clicked, the OnMouseOver event in UMG does not fire. The player need to click and hold on something and in the world and change his view while he is holding it.

Does anyone know how to fire the OnMouseOver event in UMG while the mouse button is being held down? Or something else to the same effect?

hey there, maybe like this:

OnMouseDown -> bool bMouseDown = true

TickEvent → if (bMouseDown) → DoSomething…

OnMouseUp -> bMouseDown = false;

Thanks for the reply but I need the OnMouseOver event to fire. The mouse down is working fine when the player is interacting with game objects in the world, but the mouse over event won’t trigger if the either mouse button is being held down.

use the OnBeginCursorOver event of the target to send a message to the firing actor telling it “target acquired” or some such nonsense. And another when OnEndCursorOver (If these events don’t work for you, you can simply keep track of cursor position and project the actors position to screen space and do your own logic.

Similar issue here:

Not sure how i completely misread your OP :).

This should do it: I tested it in our project and it worked even with the mouse down

0c1d05b86e256e63e0eb1b1ea2a6ee60d76a3fc7.png

Apologies for confusion.

Would I call the MouseOverEvent from my UMG widget? The UMG widget won’t fire the event if the mouse is pressed down.

This is the OnMouseMove event that was binded to a border in UMG
35d59cacd9139325e706a2d818c3122cefbc07fe.png

This is the widget view of the UMG with the binded border
UMg.png

The MouseOverEvent is not being called when I hover the mouse over the up arrow with a mouse button down. I have the nodes from the above post set up in my player controller.

I’ve been able to reproduce this in 4.7 but haven’t been able to find a solution. My guess is the hover check isn’t being done if the mouse is down (but i haven’t looked at the code to verify).

I also tried to get the information about the button and its screen position to perform my own logic in the blueprint with no success. I could very well be missing something. Good news is the check for begin mouse over works on world objects even if the mouse is down. :\

Hey there! I’m at 4.10.2 still facing this problem: Event On Mouse Enter / Leave nor “Is Hovered” aren’t fired while left mouse button is down. NOTE: if I doubleclick and hold left mouse button down all hover events are working just fine :\ Could possible that the problem is some where at Player Controller where I make bindings?

InputComponent->BindAction(“MoveToCursor”, IE_Pressed, this, &AMainPlayerController::LeftClick);
InputComponent->BindAction(“MoveToCursor”, IE_DoubleClick, this, &AMainPlayerController::DoubleLeftClick);

EDIT: Found that most probably it could be related to Drag’n’Drop oepration detected when you hold left mouse and move the cursor. According to Nick Darnell comment no mouse hovering events (including is hovered, on enter / leave etc) are fired during drag operations… Well, my workaround for this is to manually calculate position and size of widget and to check if mouse is within widget’s borders.

Here’s what I ended up doing : maintaining a flag at tick time indicating wether or not the mouse is over the widget :


// ----------------------------------------------------------
void UMyWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
{
	Super::NativeTick(MyGeometry, InDeltaTime);

	float X, Y;
	APlayerController * PC = GetOwningPlayer();
	if(PC == NULL)
		return;

	PC->GetMousePosition(X, Y);

	UWorld * World = GetWorld();
	UGameViewportClient* ViewportClient = (World != NULL) ? World->GetGameViewport() : NULL;
	FViewport* Viewport = (ViewportClient != NULL) ? ViewportClient->Viewport : NULL;
	if(Viewport != NULL)
	{	
		FIntPoint AbsM = Viewport->ViewportToVirtualDesktopPixel(FVector2D(X/float(Viewport->GetSizeXY().X), Y/float(Viewport->GetSizeXY().Y)));				  
		bIsMouseOver = MyGeometry.IsUnderLocation(FVector2D(AbsM.X, AbsM.Y));
	}
}