Skip to content

Commit

Permalink
better getcOomponentOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Oct 28, 2024
1 parent e45d4cf commit 8b0281f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions haxe/ui/backend/ComponentImpl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class ComponentImpl extends ComponentBase {
}
}

private var _componentOffset:Point = new Point(0, 0);
private override function getComponentOffset():Point {
var p:DisplayObjectContainer = this;
var s:DisplayObjectContainer = null;
Expand All @@ -254,10 +255,13 @@ class ComponentImpl extends ComponentBase {
p = p.parent;
}
if (s == null) {
return new Point(0, 0);
_componentOffset.x = 0;
_componentOffset.y = 0;
} else {
_componentOffset.x = s.x;
_componentOffset.y = s.y;
}
var globalPoint = s.localToGlobal(new openfl.geom.Point(0, 0));
return new Point(globalPoint.x, globalPoint.y);
return _componentOffset;
}

private override function handleFrameworkProperty(id:String, value:Any) {
Expand Down

0 comments on commit 8b0281f

Please sign in to comment.