PG Does not work in v5.00 does in 4.2

https://www.babylonjs-playground.com/#VE33T#6 ref Show a popup when the mouse touch a 3d object - #9 by ob1

This seems to be the cause:

https://github.com/BabylonJS/Babylon.js/commit/e73fbac7a61726c7758a8811d1fd55511f7246b0#diff-2030ddf125d5849941726ee37fe923298ed9ca3d1143706a474d3080f0b0d073

by @flux159

The PG is bugged in the first place. It should not be:

butt1 = new BABYLON.GUI.Button.CreateSimpleButton("butt"+i, "");

but:

butt1 = BABYLON.GUI.Button.CreateSimpleButton("butt"+i, "");

Javascript is forgiving and by chance it is (was) working, but you would have had an error with Typescript with the first syntax.

2 Likes

Yep, the reason I updated to this is because it works for subclasses of Buttons as well (ie the FocusableButton added) - updating to use the fix that @Evgeni_Popov suggested is the correct - https://www.babylonjs-playground.com/#VE33T#22

CreateSimpleButton is a static function of Button & shouldn’t use a new constructor.

@Evgeni_Popov had a pull request to change this back to Button at one point in Fix static helpers of the Button class by Popov72 · Pull Request #9516 · BabylonJS/Babylon.js · GitHub, but wasn’t landed.