diff options
Diffstat (limited to 'scene/gui/base_button.cpp')
-rw-r--r-- | scene/gui/base_button.cpp | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index da2ef6c5ec..0338326bbe 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -81,42 +81,50 @@ void BaseButton::gui_input(const Ref<InputEvent> &p_event) { } void BaseButton::_notification(int p_what) { - if (p_what == NOTIFICATION_MOUSE_ENTER) { - status.hovering = true; - update(); - } + switch (p_what) { + case NOTIFICATION_MOUSE_ENTER: { + status.hovering = true; + update(); + } break; - if (p_what == NOTIFICATION_MOUSE_EXIT) { - status.hovering = false; - update(); - } - if (p_what == NOTIFICATION_DRAG_BEGIN || p_what == NOTIFICATION_SCROLL_BEGIN) { - if (status.press_attempt) { - status.press_attempt = false; + case NOTIFICATION_MOUSE_EXIT: { + status.hovering = false; update(); - } - } + } break; - if (p_what == NOTIFICATION_FOCUS_ENTER) { - update(); - } + case NOTIFICATION_DRAG_BEGIN: + case NOTIFICATION_SCROLL_BEGIN: { + if (status.press_attempt) { + status.press_attempt = false; + update(); + } + } break; - if (p_what == NOTIFICATION_FOCUS_EXIT) { - if (status.press_attempt) { - status.press_attempt = false; - update(); - } else if (status.hovering) { + case NOTIFICATION_FOCUS_ENTER: { update(); - } - } + } break; - if (p_what == NOTIFICATION_EXIT_TREE || (p_what == NOTIFICATION_VISIBILITY_CHANGED && !is_visible_in_tree())) { - if (!toggle_mode) { - status.pressed = false; - } - status.hovering = false; - status.press_attempt = false; - status.pressing_inside = false; + case NOTIFICATION_FOCUS_EXIT: { + if (status.press_attempt) { + status.press_attempt = false; + update(); + } else if (status.hovering) { + update(); + } + } break; + + case NOTIFICATION_VISIBILITY_CHANGED: + case NOTIFICATION_EXIT_TREE: { + if (p_what == NOTIFICATION_VISIBILITY_CHANGED && is_visible_in_tree()) { + break; + } + if (!toggle_mode) { + status.pressed = false; + } + status.hovering = false; + status.press_attempt = false; + status.pressing_inside = false; + } break; } } |