FGeometry::AbsoluteToLocal
#include "Layout/Geometry.h"
Access: public
Specifiers: FORCEINLINE_DEBUGGABLEconst
Description
Transforms a point from absolute space into this widget's local space by inverting the accumulated render transform.
Caveats & Gotchas
- • Involves a render-transform matrix inverse, which is slightly more expensive than LocalToAbsolute. Avoid calling per-frame in tight loops; cache the result when transforming many points against the same geometry.
- • If the widget has a non-invertible render transform (e.g., scale of zero), the result is undefined. This is an edge case but can occur if a widget is animated to scale 0.
- • The input is expected in the same absolute space as LocalToAbsolute produces — be careful when mixing input from OS cursor events (desktop space) versus Slate's internal window space.
Signature
FORCEINLINE_DEBUGGABLE UE::Slate::FDeprecateVector2DResult AbsoluteToLocal(UE::Slate::FDeprecateVector2DParameter AbsoluteCoordinate) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| AbsoluteCoordinate | UE::Slate::FDeprecateVector2DParameter | A point in absolute (screen or window) space. | — |
Return Type
UE::Slate::FDeprecateVector2DResult Example
Convert mouse position to widget-local space C++
FReply UMyWidget::NativeOnMouseMove(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)
{
FVector2f LocalPos = FVector2f(InGeometry.AbsoluteToLocal(InMouseEvent.GetScreenSpacePosition()));
// LocalPos is now relative to this widget's top-left corner.
return FReply::Handled();
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
| 5.5 | stable | — |
Feedback
Was this helpful?