diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-07-08 11:48:33 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-07-08 11:48:33 +0200 |
commit | 9804a8eb307cc9733fc3b7a80bb61b616cb34be0 (patch) | |
tree | 095ff1b2c30bb83f4c3ee80cf2b810c09f7da5a4 /scene/gui/popup_menu.cpp | |
parent | f4bf25cb357e96c6730cf85522f96948f4528b45 (diff) | |
parent | eddc9cea117ac13ee357bc66740633d01d2ae084 (diff) | |
download | redot-engine-9804a8eb307cc9733fc3b7a80bb61b616cb34be0.tar.gz |
Merge pull request #94061 from bruvzg/menu_is_native
[NativeMenu] Do not auto toggle check/multi-state items. Add `is_native_menu` method.
Diffstat (limited to 'scene/gui/popup_menu.cpp')
-rw-r--r-- | scene/gui/popup_menu.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 4f07fdb87b..7f795ea710 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -2314,6 +2314,16 @@ bool PopupMenu::is_prefer_native_menu() const { return prefer_native; } +bool PopupMenu::is_native_menu() const { +#ifdef TOOLS_ENABLED + if (is_part_of_edited_scene()) { + return false; + } +#endif + + return global_menu.is_valid(); +} + bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_for_global_only) { ERR_FAIL_COND_V(p_event.is_null(), false); Key code = Key::NONE; @@ -2643,6 +2653,7 @@ void PopupMenu::_bind_methods() { ClassDB::bind_method(D_METHOD("set_prefer_native_menu", "enabled"), &PopupMenu::set_prefer_native_menu); ClassDB::bind_method(D_METHOD("is_prefer_native_menu"), &PopupMenu::is_prefer_native_menu); + ClassDB::bind_method(D_METHOD("is_native_menu"), &PopupMenu::is_native_menu); ClassDB::bind_method(D_METHOD("add_item", "label", "id", "accel"), &PopupMenu::add_item, DEFVAL(-1), DEFVAL(0)); ClassDB::bind_method(D_METHOD("add_icon_item", "texture", "label", "id", "accel"), &PopupMenu::add_icon_item, DEFVAL(-1), DEFVAL(0)); |