Skip to content

Commit

Permalink
[macOS] Fix non-global native menu shortcuts.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruvzg committed Mar 27, 2024
1 parent 7d151c8 commit 37e0be3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions platform/macos/display_server_macos.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ class DisplayServerMacOS : public DisplayServer {
NSImage *_convert_to_nsimg(Ref<Image> &p_image) const;
Point2i _get_screens_origin() const;

void set_menu_delegate(NSMenu *p_menu);

void send_event(NSEvent *p_event);
void send_window_event(const WindowData &p_wd, WindowEvent p_event);
void release_pressed_events();
Expand Down
4 changes: 4 additions & 0 deletions platform/macos/display_server_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@
displays_arrangement_dirty = false;
}

void DisplayServerMacOS::set_menu_delegate(NSMenu *p_menu) {
[p_menu setDelegate:menu_delegate];
}

Point2i DisplayServerMacOS::_get_screens_origin() const {
// Returns the native top-left screen coordinate of the smallest rectangle
// that encompasses all screens. Needed in get_screen_position(),
Expand Down
5 changes: 5 additions & 0 deletions platform/macos/native_menu_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@
RID NativeMenuMacOS::create_menu() {
MenuData *md = memnew(MenuData);
md->menu = [[NSMenu alloc] initWithTitle:@""];
[md->menu setAutoenablesItems:NO];
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
if (ds) {
ds->set_menu_delegate(md->menu);
}
RID rid = menus.make_rid(md);
menu_lookup[md->menu] = rid;
return rid;
Expand Down

0 comments on commit 37e0be3

Please sign in to comment.