Fix NativeMenu layout direction on macOS, add extra check for Windows menu.
This commit is contained in:
parent
0175be8948
commit
3459aaa9d1
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user