Skip to content

Commit

Permalink
Fix NativeMenu layout direction on macOS, add extra check for Windows…
Browse files Browse the repository at this point in the history
… menu.
  • Loading branch information
bruvzg committed Mar 15, 2024
1 parent 0175be8 commit 3459aaa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion platform/macos/native_menu_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
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) {
Expand Down
4 changes: 2 additions & 2 deletions platform/windows/native_menu_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/popup_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3459aaa

Please sign in to comment.