Closed hopewise closed 7 years ago
Floating
widget relies on stage resize event. So maybe openfl does not emit this event if canvas size changed manually? You can try to dispatch it manually:
Lib.current.stage.dispatchEvent(new Event(Event.RESIZE));
I tried to resize the Canvas, using jQuery:
$("#openfl_canvas_id").attr("width", new_width);
Then I did:
haxe.Timer.delay(function(){
openfl.Lib.current.stage.dispatchEvent(new Event(Event.RESIZE));
}, 100);
I had to pass the new width to root Floating manually, I did:
var root:Floating = UIBuilder.get('root').as(Floating);
root.resize(new_width, root.h);
root.refresh();
but I've noticed that children of root
Floating was not invalidated, the expected behavior is that children of resized Floating, should be invalidated once I refresh their parent size, but that did not happen.
Please advice.
How do you define size of children? Do you use widthPt/heightPt
?
yes
Can you provide a minimal example?
I am checking with openFL it self, I am not sure .. I will let you know though
ok, I found the solution, the problem is not with stablexUI. The solution was, I had to revalidate the window itself right after resizing the Canvas as:
var evt = document.createEvent('UIEvents'); evt.initUIEvent('resize', true, false,window,0); window.dispatchEvent(evt);
Thank you
on-resize works well when window of browser get resized. but, I have other scenario, where user changes the canvas size.
I tried:
where w is the new width of the openfl canvas, but, nothing happened. I want to achieve the same result I get when the whole window resized, but when resizing the Canvas instead.
What I expect, that all children sizes of the root get re-validated again.
Please advice.