Getting mouse location in UMG

An explanation to the problem:
I have a map widget which is a square, inside another widget’s Canvas Panel. The map widget holds all the functionality for the map like panning, zooming, etc. The map widget is comprised of an Overlay which the map image in, as well as another Overlay in that for POIs. What I am failing to create is making a waypoint marker at the mouse position when the mouse is clicked, and only in this map widget, and then be able to convert that position to the world (this conversion should be quite easy, it’s the getting the cursor position that I’m stumped on).

Anyway, I’m not overriding the mouse functions as I’m using Input Actions instead, so using Absolute to Local won’t work (to my knowledge, as it needs a geometry input that I don’t have). I’ve tried using Get Mouse Position from the Player Controller, and that doesn’t seem to work either, as it uses the whole screen size instead of this map widget’s size. I’ve also tried to Map Range the Get Mouse Position values to no avail.

Any responses would be appreciated!

You will need to use widget geometry for this, otherwise it’s going to get really ugly.

The mouse event spits out screen space, too - you translated it into the local coordinates of the widget (you may need to do it more than once if you have a nested hierarchy - windows inside windows…)

Once you have local coords and know world coords → MapRange is your friend.

Anyway, I’m not overriding the mouse functions as I’m using Input Actions instead,

Perhaps you could explain the reasoning behind this choice. Sometimes there is a good one, other times it’s a dead end. Widgets are fine with processing input and this produces the necessary data for a lot of operations.

1 Like

I’m using Input Actions because the inputs from both keyboard, mouse and controller are customisable, and need to have those three instead of just the mouse. The link you sent looks similar to how I’d have done it if I did override the functions to get that geometry. Is there another way to the widget geometry that those functions provide without overriding them?

Edit: I’ll be using Common UI’s input system later on when concrete documentation or tutorials are available as currently it’s very lacking.


You may be the target audience for this node.

Do note that widgets can also:

But I’ve never used it so not sure if that would help you. Worth looking into as an alternative if all else fails. Or maybe even before dealing with cached geometry.

1 Like

Also, you could store widget geometry during onMouseMove but process it only when controller action gets evoked. Not sure how different that would be from the cached one, though.

Get Cached Geometry looks very promising. It seems I forgot I also need the Absolute Coordinate, which would be Get Screen Space Position, but I don’t have access to a Pointer Event Structure for that, as that would be from those overridden functions also. There doesn’t seem to be anything I can use outside of those functions for it either. I would set my own variable to one of the function’s inputs, but it’s that the mouse may never be used, so that variable will never get set in the first place, which I assume would break it.