summaryrefslogtreecommitdiff
path: root/scene/gui/menu_bar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/menu_bar.cpp')
-rw-r--r--scene/gui/menu_bar.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp
index 9b7b67d83e..788b320b46 100644
--- a/scene/gui/menu_bar.cpp
+++ b/scene/gui/menu_bar.cpp
@@ -95,7 +95,7 @@ void MenuBar::gui_input(const Ref<InputEvent> &p_event) {
selected_menu = focused_menu;
}
if (selected_menu != old_sel) {
- update();
+ queue_redraw();
}
}
@@ -143,16 +143,12 @@ void MenuBar::_open_popup(int p_index, bool p_focus_item) {
}
}
- update();
+ queue_redraw();
}
void MenuBar::shortcut_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
- if (is_native_menu()) {
- return;
- }
-
if (!_is_focus_owner_in_shortcut_context()) {
return;
}
@@ -212,7 +208,7 @@ void MenuBar::_popup_visibility_changed(bool p_visible) {
active_menu = -1;
focused_menu = -1;
set_process_internal(false);
- update();
+ queue_redraw();
return;
}
@@ -253,7 +249,7 @@ void MenuBar::_update_submenu(const String &p_menu_name, PopupMenu *p_child) {
DisplayServer::get_singleton()->global_menu_add_submenu_item(p_menu_name, p_child->get_item_text(i), p_menu_name + "/" + itos(i));
_update_submenu(p_menu_name + "/" + itos(i), pm);
} else {
- int index = DisplayServer::get_singleton()->global_menu_add_item(p_menu_name, p_child->get_item_text(i), callable_mp(p_child, &PopupMenu::activate_item), i);
+ int index = DisplayServer::get_singleton()->global_menu_add_item(p_menu_name, p_child->get_item_text(i), callable_mp(p_child, &PopupMenu::activate_item), Callable(), i);
if (p_child->is_item_checkable(i)) {
DisplayServer::get_singleton()->global_menu_set_item_checkable(p_menu_name, index, true);
@@ -337,7 +333,7 @@ void MenuBar::_update_menu() {
}
}
update_minimum_size();
- update();
+ queue_redraw();
}
void MenuBar::_notification(int p_what) {
@@ -352,7 +348,7 @@ void MenuBar::_notification(int p_what) {
} break;
case NOTIFICATION_MOUSE_EXIT: {
focused_menu = -1;
- update();
+ queue_redraw();
} break;
case NOTIFICATION_TRANSLATION_CHANGED:
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
@@ -376,12 +372,24 @@ void MenuBar::_notification(int p_what) {
case NOTIFICATION_INTERNAL_PROCESS: {
MutexLock lock(mutex);
+ if (is_native_menu()) {
+ // Handled by OS.
+ return;
+ }
+
Vector2 pos = DisplayServer::get_singleton()->mouse_get_position() - mouse_pos_adjusted - get_global_position();
+ if (pos == old_mouse_pos) {
+ return;
+ }
+ old_mouse_pos = pos;
+
int index = _get_index_at_point(pos);
if (index >= 0 && index != active_menu) {
selected_menu = index;
focused_menu = selected_menu;
- get_menu_popup(active_menu)->hide();
+ if (active_menu >= 0) {
+ get_menu_popup(active_menu)->hide();
+ }
_open_popup(index);
}
} break;
@@ -716,7 +724,7 @@ String MenuBar::get_language() const {
void MenuBar::set_flat(bool p_enabled) {
if (flat != p_enabled) {
flat = p_enabled;
- update();
+ queue_redraw();
}
}