Skip to content

Commit 58948df

Browse files
committed
allow screen width/height to be root components
1 parent 600db38 commit 58948df

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

haxe/ui/backend/ScreenBase.hx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,28 @@ class ScreenBase {
4141

4242
public var width(get, null):Float;
4343
private function get_width():Float {
44-
return container.offsetWidth;
44+
var cx:Float = container.offsetWidth;
45+
if (cx <= 0) {
46+
for (c in __topLevelComponents) {
47+
if (c.width > cx) {
48+
cx = c.width;
49+
}
50+
}
51+
}
52+
return cx;
4553
}
4654

4755
public var height(get, null):Float;
4856
private function get_height():Float {
49-
return container.offsetHeight;
57+
var cy:Float = container.offsetHeight;
58+
if (cy <= 0) {
59+
for (c in __topLevelComponents) {
60+
if (c.height > cy) {
61+
cy = c.height;
62+
}
63+
}
64+
}
65+
return cy;
5066
}
5167

5268
public var dpi(get, null):Float;

0 commit comments

Comments
 (0)