RealDocs

USlateBlueprintLibrary::AbsoluteToViewport

function UMG Blueprint Since 4.7
#include "Blueprint/SlateBlueprintLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Converts an absolute desktop-space coordinate into both viewport pixel space and UMG viewport widget space. Useful when you have an absolute position from LocalToAbsolute and need viewport-relative coordinates.

Caveats & Gotchas

  • Unlike LocalToViewport, this function does not take a geometry parameter — the absolute coordinate must already be in desktop space, not just window space. Mixing them up causes positional offset in windowed mode.
  • In PIE (Play In Editor) with multiple viewports the viewport offset relative to the desktop can shift between frames; always re-query rather than caching PixelPosition across frames.
  • Returns zero for both outputs without assertion if no GameViewportClient is found.

Signature

static UMG_API void AbsoluteToViewport(const UObject* WorldContextObject, FVector2D AbsoluteDesktopCoordinate, FVector2D& PixelPosition, FVector2D& ViewportPosition)

Parameters

Name Type Description Default
WorldContextObject const UObject* World context used to resolve the game viewport client.
AbsoluteDesktopCoordinate FVector2D Coordinate in absolute desktop space (as returned by LocalToAbsolute or mouse event GetScreenSpacePosition).
PixelPosition FVector2D& Output: position in game viewport pixel space.
ViewportPosition FVector2D& Output: position in UMG viewport widget space.

Return Type

void

Example

Convert a widget's absolute position to viewport pixel space C++
FVector2D AbsPos = USlateBlueprintLibrary::LocalToAbsolute(
	MyWidget->GetCachedGeometry(), FVector2D::ZeroVector);
FVector2D PixelPos, ViewportPos;
USlateBlueprintLibrary::AbsoluteToViewport(GetWorld(), AbsPos, PixelPos, ViewportPos);

Version History

Introduced in: 4.7

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.