# Mouse Position on Viewport in Editor mode

**URL:** <https://forums.unrealengine.com/t/mouse-position-on-viewport-in-editor-mode/246501>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [August 20, 2021, 10:17am UTC](https://forums.unrealengine.com/t/mouse-position-on-viewport-in-editor-mode/246501 "2021-08-20T10:17:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mustache\_works](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mustache\_works](https://forums.unrealengine.com/u/mustache_works)\
**Post date:** [August 20, 2021, 10:17am UTC](https://forums.unrealengine.com/t/mouse-position-on-viewport-in-editor-mode/246501/1 "2021-08-20T10:17:40Z")

</div>

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](https://docs.unrealengine.com/4.27/en-US/BlueprintAPI/Viewport/GetMousePositiononViewport/) 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?

Cheers,  
.

---

<div class="post-metadata">

**Author:** ![Est\_engine](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/est_engine/32/1008648_2.png) [@Est\_engine](https://forums.unrealengine.com/u/Est_engine)\
**Post date:** [August 20, 2021, 2:08pm UTC](https://forums.unrealengine.com/t/mouse-position-on-viewport-in-editor-mode/246501/2 "2021-08-20T14:08:46Z")

</div>

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

> [@"Get Mouse Position on Viewport"](https://forums.unrealengine.com/t/get-mouse-position-on-viewport/111399):
>
> Hello, i found a really bad bug or what ever this is. I have a print screen node there that shows: Viewport resolution (Get Viewport Size) Mouse position (Get Mouse Position on Viewport) My Windows resolution is 2560x1440. The “Get Viewport Size” works fine, i even test this with Photoshop and cutout that viewport and it was 1:1. So it works fine. But “Get Mouse Position on Viewport” is so off it’s just insane. In the video i stretch the game window and the values where insane! Even tho my…

---

<div class="post-metadata">

**Author:** ![mustache\_works](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mustache\_works](https://forums.unrealengine.com/u/mustache_works)\
**Post date:** [August 20, 2021, 5:40pm UTC](https://forums.unrealengine.com/t/mouse-position-on-viewport-in-editor-mode/246501/3 "2021-08-20T17:40:27Z")

</div>

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.

 ![Screenshot_12](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/2/3249cc26e936518610d501aee807b6cac1f9b88b.jpeg)

---

<div class="post-metadata">

**Author:** ![mustache\_works](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mustache\_works](https://forums.unrealengine.com/u/mustache_works)\
**Post date:** [August 23, 2021, 8:04pm UTC](https://forums.unrealengine.com/t/mouse-position-on-viewport-in-editor-mode/246501/4 "2021-08-23T20:04:00Z")

</div>

anyone?

---

<div class="post-metadata">

**Author:** ![L05](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@L05](https://forums.unrealengine.com/u/L05)\
**Post date:** [January 19, 2022, 9:18pm UTC](https://forums.unrealengine.com/t/mouse-position-on-viewport-in-editor-mode/246501/5 "2022-01-19T21:18:28Z")

</div>

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

```auto
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.

 ![GetActiveViewportMousePos](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/5/25b3eaa8565b9ca1370d18fc5929ce7af02025f1.png)
