| 387 | } |
| 388 | |
| 389 | void 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 | |
| 420 | void AcceptDialog::_bind_methods() { |
| 421 | ClassDB::bind_method(D_METHOD("get_ok_button"), &AcceptDialog::get_ok_button); |
nothing calls this directly
no test coverage detected