diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/popup_menu.cpp | 6 | ||||
-rw-r--r-- | scene/gui/tab_bar.cpp | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 6e0f1c5198..b26b9d1225 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -844,7 +844,7 @@ void PopupMenu::_notification(int p_what) { #define ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel) \ item.text = p_label; \ item.xl_text = atr(p_label); \ - item.id = p_id == -1 ? items.size() - 1 : p_id; \ + item.id = p_id == -1 ? items.size() : p_id; \ item.accel = p_accel; void PopupMenu::add_item(const String &p_label, int p_id, Key p_accel) { @@ -926,7 +926,7 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int _ref_shortcut(p_shortcut); \ item.text = p_shortcut->get_name(); \ item.xl_text = atr(item.text); \ - item.id = p_id == -1 ? items.size() - 1 : p_id; \ + item.id = p_id == -1 ? items.size() : p_id; \ item.shortcut = p_shortcut; \ item.shortcut_is_global = p_global; @@ -995,7 +995,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, Item item; item.text = p_label; item.xl_text = atr(p_label); - item.id = p_id == -1 ? items.size() - 1 : p_id; + item.id = p_id == -1 ? items.size() : p_id; item.submenu = p_submenu; items.push_back(item); _shape_item(items.size() - 1); diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index 5a551ec5a5..b1baacd887 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -761,6 +761,8 @@ void TabBar::_update_hover() { return; } + ERR_FAIL_COND(tabs.is_empty()); + const Point2 &pos = get_local_mouse_position(); // Test hovering to display right or close button. int hover_now = -1; @@ -1436,7 +1438,6 @@ void TabBar::_get_property_list(List<PropertyInfo> *p_list) const { } void TabBar::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_hover"), &TabBar::_update_hover); ClassDB::bind_method(D_METHOD("set_tab_count", "count"), &TabBar::set_tab_count); ClassDB::bind_method(D_METHOD("get_tab_count"), &TabBar::get_tab_count); ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &TabBar::set_current_tab); |