Below is a Youtube video demoing the issue. In short, when I click I can no longer move my mouse. I believe I have narrowed it down to the Get Mouse Position function. Is there a different function I should be using to get the current mouse position. It updates the position of one of my UI widgets.
Thanks for any help!
I just ran unto the same issue. I don’t know why GetMousePosition doesn’t update when a mouse button is held, it may be by design, but this blueprint might help. What I did was store the mouse position when the button is pressed and then update that position every event tick using GetMouseX and GetMouseY. I had to invert the Y because I was drawing something in the HUD that had to follow the cursor. I know you have a different issue to solve but maybe this can give you some ideas.
The “Get Mouse Position on Viewport” function seems to be working pretty well, even with pressed mousebutton.
In SButton::OnMouseButtonDown
, depending on the EButtonClickMethod
, the Reply
will be marked with FReply::Handled().CaptureMouse( AsShared() );
, which “captures the mouse”. I believe this is what is causing GetMousePosition
not to update while a mouse button is pressed. I think if you use one of the other ButtonClickMethods like MouseDown
or PreciseClick
you won’t get this effect.
Yes as I suspected, I can confirm that either SetClickMethod(MouseDown)
or SetClickMethod(PreciseClick)
fixes it. MouseDown
has the effect of calling OnClicked
immediately OnPressed
, but you still receive OnReleased
events as normal. PreciseClick
seems to fire the OnReleased
event when you move the mouse and I guess doesn’t fire OnClicked
when this happens.