MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / remove_button

Method remove_button

scene/gui/dialogs.cpp:389–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387}
388
389void AcceptDialog::remove_button(Button *p_button) {
390 ERR_FAIL_NULL(p_button);
391 ERR_FAIL_COND_MSG(p_button->get_parent() != buttons_hbox, vformat("Cannot remove button %s as it does not belong to this dialog.", p_button->get_name()));
392 ERR_FAIL_COND_MSG(p_button == ok_button, "Cannot remove dialog's OK button.");
393
394 Control *bound_spacer = Object::cast_to<Control>(p_button->get_meta("__bound_spacer"));
395 if (bound_spacer) {
396 ERR_FAIL_COND_MSG(bound_spacer->get_parent() != buttons_hbox, vformat("Cannot remove button %s as its associated spacer does not belong to this dialog.", p_button->get_name()));
397 }
398
399 p_button->disconnect(SceneStringName(visibility_changed), callable_mp(this, &AcceptDialog::_button_visibility_changed));
400 if (p_button->is_connected(SceneStringName(pressed), callable_mp(this, &AcceptDialog::_custom_action))) {
401 p_button->disconnect(SceneStringName(pressed), callable_mp(this, &AcceptDialog::_custom_action));
402 }
403 if (p_button->is_connected(SceneStringName(pressed), callable_mp(this, &AcceptDialog::_cancel_pressed))) {
404 p_button->disconnect(SceneStringName(pressed), callable_mp(this, &AcceptDialog::_cancel_pressed));
405 }
406
407 if (bound_spacer) {
408 buttons_hbox->remove_child(bound_spacer);
409 p_button->remove_meta("__bound_spacer");
410 bound_spacer->queue_free();
411 }
412 buttons_hbox->remove_child(p_button);
413
414 child_controls_changed();
415 if (is_visible()) {
416 _update_child_rects();
417 }
418}
419
420void AcceptDialog::_bind_methods() {
421 ClassDB::bind_method(D_METHOD("get_ok_button"), &AcceptDialog::get_ok_button);

Callers

nothing calls this directly

Calls 9

vformatFunction · 0.85
disconnectMethod · 0.65
get_parentMethod · 0.45
get_nameMethod · 0.45
get_metaMethod · 0.45
is_connectedMethod · 0.45
remove_childMethod · 0.45
remove_metaMethod · 0.45
queue_freeMethod · 0.45

Tested by

no test coverage detected