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
- Optionally, set ShowMouseCursor to
trueto 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
PressPointerKeyfunction on the WidgetInteractionComponent (WIC) and set Left Mouse Button as the Key.
- From InputAction Fire’s Released exec pin call
ReleasePointerKeyon the WIC and set Left Mouse Button as the Key.
- Right after the
PrintStringand print the PlayerController’s
GetMousePositionvalues, 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.
Mouse position is reported as either X=0 Y=0 or some other random values.
Mouse position to be equivalent to the mouse pixel location on screen, as it is when not in Immersive mode.
To read the mouse position before releasing the pointer key on the WIC.
This also affects the results of the