Mouse Position on Viewport in Editor mode

Hello everybody,

i’m scripting a tool to help level design. I’m looking for a way to find mouse position on viewport BUT in editor mode.

I’m using the Get Mouse Position on Viewport Node but it returns whole screen values (same as Get Mouse Position on Platform).

Is there a way to translate those values to the viewport window space?


hi @mustache_works
take a look at this and let me know if is what you need

Yeah I’ve seen it. Unfortunately the solution doesn’t work in editor mode. (Or at least not in a straightforward way).

Get Mouse Position on Viewport returns fullscreen values even though the level viewport is a docked window (default ue layout).

Mouse in the upper left corner.


I was able to expose the editor viewport mouse position by creating a Blueprint Function as part of a Blueprint Function Library.

bool UBFL_EditorUtilities::GetActiveViewportMousePos(int32& mouseX, int32& mouseY, float& mouseU, float& mouseV)
	FIntPoint mousePos;
	GEditor->GetActiveViewport()->GetMousePos(mousePos, true);
	mouseX = mousePos.X;
	mouseY = mousePos.Y;
	mouseU = float(mouseX) / float(GEditor->GetActiveViewport()->GetSizeXY().X);
	mouseV = float(mouseY) / float(GEditor->GetActiveViewport()->GetSizeXY().Y);
	return (GEditor->GetActiveViewport() != NULL);

This enables me to get the mouse X and Y position relative to the editor viewport from within an Editor Utility Widget, as well as the UV position for use in a post processing shader.

1 Like