anthony.liot Posted October 10, 2013 Posted October 10, 2013 Hi, I need to use the color picker inside our interface, but we doesn't want use like an WidgetDialog.I try something for access directly to the hbox child inside the WDC. color = new WidgetDialogColor(gui); Widget color_hbox = color.getChild(0); log.message("Num child inside hbox : "+color_hbox.getNumChilds()+"\n"); // <-- Return "Num child inside hbox : 2" But when i try to use it : my_script_hbox.addChild(color_hbox.getChild(0)); // <-- Oki I have the picker part of the color picker my_script_hbox.addChild(color_hbox.getChild(1)); // <-- Assert Invalid num of child If i try to do similar things with for loop : for (int i = 0 ; i < color_hbox.getNumChilds(); i++) { log.message("Add child : %d\n",i); // <-- This message it's print just one time my_script_hbox.addChild(color_hbox.getChild(i)); } If i try other loop like : for (int i = 0 ; i < 2; i++) { log.message("Add child : %d\n",i); // <-- This message it's print two time my_script_hbox.addChild(color_hbox.getChild(i)); // <-- first ok : second crash } Just for info, it's a little weird ....
frustum Posted October 14, 2013 Posted October 14, 2013 But when i try to use it : my_script_hbox.addChild(color_hbox.getChild(0)); // <-- Oki I have the picker part of the color picker my_script_hbox.addChild(color_hbox.getChild(1)); // <-- Assert Invalid num of child This behavior is correct. The my_script_hbox.addChild() function moves the first widget from color_hbox into the my_script_hbox. And there is only one child widget inside color_hbox after that. my_script_hbox.addChild(color_hbox.getChild(0)); my_script_hbox.addChild(color_hbox.getChild(0)); Widget widgets[0]; forloop(int i = 0; color_hbox.getNumChilds()) widgets.append(color_hbox.getChild(i)); my_script_hbox.addChild(widgets[0]); my_script_hbox.addChild(widgets[1]);
anthony.liot Posted October 14, 2013 Author Posted October 14, 2013 Hi Frustum, I was surprise because the code was working before, it's for that i say weird ;) Thanks for the info.
Recommended Posts