From 12386a2d8035efb1714b264fe14480f4cdb8d5cd Mon Sep 17 00:00:00 2001 From: nobuyuki_nyuu Date: Wed, 6 May 2020 15:27:35 -0500 Subject: [PATCH] PopupMenu.get_current_index() bound to ClassDB (cherry picked from commit 35f30086de7069df2854949948ae26642c5a1452) --- scene/gui/popup_menu.cpp | 6 ++++++ scene/gui/popup_menu.h | 1 + 2 files changed, 7 insertions(+) diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index ed3495dadf3..571fd5f5043 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -1063,6 +1063,11 @@ bool PopupMenu::is_item_shortcut_disabled(int p_idx) const { return items[p_idx].shortcut_is_disabled; } +int PopupMenu::get_current_index() const { + + return mouse_over; +} + int PopupMenu::get_item_count() const { return items.size(); @@ -1443,6 +1448,7 @@ void PopupMenu::_bind_methods() { ClassDB::bind_method(D_METHOD("get_item_tooltip", "idx"), &PopupMenu::get_item_tooltip); ClassDB::bind_method(D_METHOD("get_item_shortcut", "idx"), &PopupMenu::get_item_shortcut); + ClassDB::bind_method(D_METHOD("get_current_index"), &PopupMenu::get_current_index); ClassDB::bind_method(D_METHOD("get_item_count"), &PopupMenu::get_item_count); ClassDB::bind_method(D_METHOD("remove_item", "idx"), &PopupMenu::remove_item); diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index f77ede0a8bd..9d0a2dd3334 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -176,6 +176,7 @@ public: Ref get_item_shortcut(int p_idx) const; int get_item_state(int p_idx) const; + int get_current_index() const; int get_item_count() const; bool activate_item_by_event(const Ref &p_event, bool p_for_global_only = false);