Skip to content

Commit

Permalink
Merge pull request #302 from trunkmaster/menu-unhide
Browse files Browse the repository at this point in the history
NSApplication: toggle menu item "Hide" title and action on user click.
  • Loading branch information
trunkmaster authored Nov 1, 2024
2 parents 3879f8e + c575415 commit 5cd4323
Showing 1 changed file with 19 additions and 1 deletion.
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:_(@"Show")];
}

_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:_(@"Show")];
if (menuItem)
{
[menuItem setAction:@selector(hide:)];
[menuItem setTitle:_(@"Hide")];
}
if (_app_is_hidden)
{
[self unhideWithoutActivation];
Expand Down

0 comments on commit 5cd4323

Please sign in to comment.