diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-15 10:40:17 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-15 10:40:17 +0100 |
commit | 70bcf2175c7568389241067ebb3e6c7960f5ab05 (patch) | |
tree | 234e0eb601f75718db8ebd28047f19f16e699238 | |
parent | c7061d5e969c0fcca23f3dff60f015b63ef27c40 (diff) | |
parent | 3459aaa9d15466292ee5fc7d2497b2d3894da0fe (diff) | |
download | redot-engine-70bcf2175c7568389241067ebb3e6c7960f5ab05.tar.gz |
Merge pull request #89506 from bruvzg/menu_fix1
Fix NativeMenu layout direction on macOS, add extra check for Windows menu.
-rw-r--r-- | platform/macos/native_menu_macos.mm | 2 | ||||
-rw-r--r-- | platform/windows/native_menu_windows.cpp | 4 | ||||
-rw-r--r-- | scene/gui/popup_menu.cpp | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/platform/macos/native_menu_macos.mm b/platform/macos/native_menu_macos.mm index f00527767c..250b64dc04 100644 --- a/platform/macos/native_menu_macos.mm +++ b/platform/macos/native_menu_macos.mm @@ -271,7 +271,7 @@ void NativeMenuMacOS::set_interface_direction(const RID &p_rid, bool p_is_rtl) { MenuData *md = menus.get_or_null(p_rid); ERR_FAIL_NULL(md); - md->menu.userInterfaceLayoutDirection = p_is_rtl ? NSUserInterfaceLayoutDirectionLeftToRight : NSUserInterfaceLayoutDirectionRightToLeft; + md->menu.userInterfaceLayoutDirection = p_is_rtl ? NSUserInterfaceLayoutDirectionRightToLeft : NSUserInterfaceLayoutDirectionLeftToRight; } void NativeMenuMacOS::set_popup_open_callback(const RID &p_rid, const Callable &p_callback) { diff --git a/platform/windows/native_menu_windows.cpp b/platform/windows/native_menu_windows.cpp index eea30cab9a..84e3611e91 100644 --- a/platform/windows/native_menu_windows.cpp +++ b/platform/windows/native_menu_windows.cpp @@ -289,7 +289,7 @@ int NativeMenuWindows::add_item(const RID &p_rid, const String &p_label, const C item.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_DATA; item.fType = MFT_STRING; item.dwItemData = (ULONG_PTR)item_data; - item.dwTypeData = (LPWSTR)label.ptrw(); + item.dwTypeData = label.ptrw() ? (LPWSTR)label.ptrw() : L""; if (!InsertMenuItemW(md->menu, p_index, true, &item)) { memdelete(item_data); @@ -949,7 +949,7 @@ void NativeMenuWindows::set_item_text(const RID &p_rid, int p_idx, const String item.cbSize = sizeof(item); item.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_DATA; if (GetMenuItemInfoW(md->menu, p_idx, true, &item)) { - item.dwTypeData = (LPWSTR)label.ptrw(); + item.dwTypeData = label.ptrw() ? (LPWSTR)label.ptrw() : L""; SetMenuItemInfoW(md->menu, p_idx, true, &item); } } diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 25d999851b..56346f5edc 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -92,7 +92,7 @@ RID PopupMenu::bind_global_menu() { NativeMenu *nmenu = NativeMenu::get_singleton(); - if (system_menu_id != NativeMenu::INVALID_MENU_ID) { + if (system_menu_id != NativeMenu::INVALID_MENU_ID && nmenu->has_system_menu(system_menu_id)) { if (system_menus.has(system_menu_id)) { WARN_PRINT(vformat("Attempting to bind PopupMenu to the system menu %s, but another menu is already bound to it. This menu: %s, current menu: %s", nmenu->get_system_menu_name(system_menu_id), get_description(), system_menus[system_menu_id]->get_description())); global_menu = nmenu->create_menu(); |