Both Tick and WindowsApplicationMessage fires OnMouseMove if mouse is hovered on widget.
So, This increases OnMouseMove’s rate of fire more higher than tick operation.
Is this Setup intended and normal? I think OnMouseMove should fire once a tick.
You can reproduce this by counting executions of both function.
This is by design: we create a synthetic mouse move in order to account for any changing that the UI might do while the mouse remains stationary. E.g. an animated button might slide in under the cursor; Slate handles this by pretending that the cursor moved.
The information present in the mouse move event is more than sufficient to create the correct behavior. We also do NOT create synthetic mouse moves when the mouse is captured. This is the case when the mouse is controlling a camera (e.g. in an FPS)
Just a reminder. If any point is not clear for second question, please let me know.
We think this post contains useful information which we would like to share with our public UE4 community. With your approval, we would like to make a copy of this post on the public AnswerHub which includes the discussion but strips out your username and company name. Please let us know if you are okay with this.
To get mouse position, I’m using second code.
But Can I use first one?
MouseEvent.GetScreenSpacePosition() - Geometry.AbsolutePosition + WidgetPosition;
const FVector2D MousePosition = MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition());
And, If OnMouseMove (2) was called in action within running OnMouseMove (1) which is causing widget move, I think AbsolutePosition of Geometry should be updated but it isn’t. What is the exact update timing of AbsolutePosition?
This causes returning non-updated Absolute Position.
I don’t really understand what you are doing with the first line of code. It does not account for scale. It also adds a
WidgetPosition, which I have no idea where that comes from in your code.
To get the cursor position within your widget you should always use
const FVector2D LocalMousePosition = MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition());
You cannot make any assumptions about how frequently
MouseMove will be called. In high precision mode you get tens of
MouseMove events per frame.
Geometry of the widget computed on-demand whenever we process events or tick/paint.
We are currently trying to deprecate
.AbsolutePosition. You should not ever need to use it.
Please share. Thanks to Nick.