Skip to content

Commit

Permalink
fixed actions and keyboard shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
hacknus committed Jan 26, 2024
1 parent dd53ac6 commit 40547fd
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions crates/eframe/src/native/app_icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! TODO(emilk): port this to [`winit`].

use std::sync::Arc;
use cocoa::appkit::NSEventModifierFlags;

use egui::IconData;

Expand Down Expand Up @@ -267,27 +268,24 @@ fn set_title_and_icon_mac(_title: &str, icon_data: Option<&IconData>) -> AppIcon
let hide_prefix = NSString::alloc(nil).init_str("Hide ");
let hide_title =
hide_prefix.stringByAppendingString_(NSProcessInfo::processInfo(nil).processName());
let hide_action = selector("hideApp:");
let hide_action = selector("hide:");
let hide_key = NSString::alloc(nil).init_str("h");
let hide_item = NSMenuItem::alloc(nil)
.initWithTitle_action_keyEquivalent_(hide_title, hide_action, hide_key)
.autorelease();
app_menu.addItem_(hide_item);

let hide_others_title = NSString::alloc(nil).init_str("Hide Others");
let hide_others_action = selector("hideOthers:");
let hide_others_key = NSString::alloc(nil).init_str("");
let hide_others_action = selector("hideOtherApplications:");
let hide_others_key = NSString::alloc(nil).init_str("h");
let hide_others_item = NSMenuItem::alloc(nil)
.initWithTitle_action_keyEquivalent_(
hide_others_title,
hide_others_action,
hide_others_key,
)
.initWithTitle_action_keyEquivalent_(hide_others_title, hide_others_action, hide_others_key)
.autorelease();
hide_others_item.setKeyEquivalentModifierMask_(NSEventModifierFlags::NSCommandKeyMask | NSEventModifierFlags::NSAlternateKeyMask);
app_menu.addItem_(hide_others_item);

let show_all_title = NSString::alloc(nil).init_str("Show All");
let show_all_action = selector("showAll:");
let show_all_action = selector("unhideAllApplications:");
let show_all_key = NSString::alloc(nil).init_str("");
let show_all_item = NSMenuItem::alloc(nil)
.initWithTitle_action_keyEquivalent_(show_all_title, show_all_action, show_all_key)
Expand Down

0 comments on commit 40547fd

Please sign in to comment.