Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSApplication: toggle title of menu item "Hide" on user action. #302

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Source/NSApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -2496,6 +2496,7 @@ - (void) hide: (id)sender
NSDictionary *info;
NSWindow *win;
NSEnumerator *iter;
id<NSMenuItem> menuItem;

[nc postNotificationName: NSApplicationWillHideNotification
object: self];
Expand Down Expand Up @@ -2543,7 +2544,16 @@ - (void) hide: (id)sender
[_hidden addObject: win];
[win orderOut: self];
}
}
}
menuItem = [sender isKindOfClass:[NSMenuItem class]]
? sender
: [_main_menu itemWithTitle:_(@"Hide")];
if (menuItem)
{
[menuItem setAction:@selector(unhide:)];
[menuItem setTitle:_(@"Unhide")];
}

_app_is_hidden = YES;

if (YES == [[NSUserDefaults standardUserDefaults]
Expand Down Expand Up @@ -2606,6 +2616,14 @@ - (BOOL) isHidden
*/
- (void) unhide: (id)sender
{
id<NSMenuItem> menuItem = [sender isKindOfClass:[NSMenuItem class]]
? sender
: [_main_menu itemWithTitle:_(@"Unhide")];
if (menuItem)
{
[menuItem setAction:@selector(hide:)];
[menuItem setTitle:_(@"Hide")];
}
if (_app_is_hidden)
{
[self unhideWithoutActivation];
Expand Down
Loading