Problem
Mouse position is 0,0 or other random invalid values if read after pressing and releasing pointer with Widget Interaction Component.
Steps to reproduce
- In project settings, add some input action using the Left Mouse Button (eg.: Fire)
- Create a BluePrint. Select Actor as it’s base type.
- Add a WidgetInteractionComponent to the BP.
- In the BP’s Event BeginPlay, Enable Input for PlayerController
0
. - Optionally, set ShowMouseCursor to
true
to see the mouse on screen during PIE. - Add the InputAction Fire to the BP’s graph.
- From InputAction Fire’s Pressed exec pin, call the
PressPointerKey
function on the WidgetInteractionComponent (WIC) and set Left Mouse Button as the Key. - From InputAction Fire’s Released exec pin call
ReleasePointerKey
on the WIC and set Left Mouse Button as the Key. - Right after the
ReleasePointerKey
node, callPrintString
and print the PlayerController’sGetMousePosition
values, like the image:
- Drag a copy of this BP into the level.
- Start a PIE session and press F11 to enter Immersive mode.
- Click to see the mouse position values printed on the screen.
Result
Mouse position is reported as either X=0 Y=0 or some other random values.
Expected result
Mouse position to be equivalent to the mouse pixel location on screen, as it is when not in Immersive mode.
Current workaround
To read the mouse position before releasing the pointer key on the WIC.
Observation
This also affects the results of the ConvertMouseLocationToWorldSpace
node.