Real-time GUI creation

Good afternoon, everyone!

I have a question, again:
I tried to create new GUI elements inside a PGButton callback function but it did not work. Is it because I am in the main loop already, when the callback function is executed? What can I do about it?
Here is the callback function (maybe it is another mistake i did not see :question:)

	PT(PGVirtualFrame) frame = new PGVirtualFrame();
	frame->setup(50, 100);

	PGFrameStyle style = frame->get_frame_style(0);
	style.set_color(0.5f, 0.7f, 0.5f, 1.0f);

	frame->set_frame_style(0, style);
	frame->set_frame_style(1, style);
	frame->set_frame_style(2, style);
	frame->set_frame_style(3, style);

	nodes[numNodes - 1] = window->get_aspect_2d().attach_new_node(frame);
	nodes[numNodes - 1].set_pos(-1.0, 0.0, -1.0);
	nodes[numNodes - 1].set_scale(0.5f);

The nodes array contains all the NodePath variables I use.
I am looking forward to helpful awnsers :slight_smile:

It probably failed because the PGButton makes a copy of the nodes you give it at construction time, and store them internally. Thus, if you modify your original node, nothing happens–you have to modify the PGButton’s copy.

Try button->get_state_def() to retrieve the internal NodePath for each state.