GUI Button width not still computed inside stackpanel

Hello,

I try to make a simple context menu which will open at the pointer position on longpress event.

If pointer position is near the bounding screen (advanced full texture) i check if the pointer position + context menu size is outside bounding screen if true i recompute the position to put the context menu inside screen.

The problem is when the first long press is triggered the width of my context menu seems to be equals to 100% of the screen width instead of the real size.

After that the second long press open the context menu at the good position because size of context menu has been recomputed correctly.

I’ve tried to play with makeDirty methods… with no success.

Is there a way to wait next frame or call a method to force the computation or better solution ?

See methods _compute… inside method showAt()
/!\ Don’t forget to press any key to fill the contextmenu
https://playground.babylonjs.com/#XCPP9Y#8475

Bonus question:
I guess it is the same kind of problem but the buttons width do not use 100% of the parent. If I use original TextWrapping.WordWrap options the stackpanel take 100% of the screen.

How to have children taking 100% of stackpanel ?

Thanks.

Hi @nanney54 , pinging @msDestiny14 to see if she has an idea.

I’ve fixed the problem with a temporary ugly piece of code.

https://playground.babylonjs.com/#XCPP9Y#8486

Better approaches are always welcome :slightly_smiling_face:

1 Like