• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How a window was closed?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How a window was closed?


  • Subject: Re: How a window was closed?
  • From: Kyle Sluder <email@hidden>
  • Date: Thu, 4 Mar 2010 09:49:50 -0800

On Thu, Mar 4, 2010 at 5:39 AM, Eric Gorr <email@hidden> wrote:
> The only method (currently) for closing the panel which seems difficult to determine is whether or not the user has clicked in the close (red) button. However, it does appear that -windowShouldClose: is the easiest way to do it.

It might be the easiest, but it seems to me like you might want a more
general-purpose solution, rather than reimplementing the same logic in
every panel's delegate.

// Warning, typed in mail. Probably won't work.
@interface MyPanel : NSPanel {
  BOOL saveVisibility;
}

@implementation MyPanel
- (void)writePreferredVisibilityToUserDefaults:(BOOL)shouldBeVisible {
  // ...
}

- (void)orderWindow:(NSWindowOrderingMode)order relativeTo:(NSInteger)windowNum
{
  if (order != NSWindowOut)
    [self writePreferredVisibilityToUserDefaults:YES];

  [super orderWindow:order relativeTo:windowNum];
}

- (void)performClose:(id)sender {
  saveVisibility = YES;
  [super performClose:sender];
}

- (void)close {
  if (saveVisibility)
    [self writePreferredVisibilityToUserDefaults:NO];

  [super close];
}

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How a window was closed?
      • From: Eric Gorr <email@hidden>
References: 
 >How a window was closed? (From: Eric Gorr <email@hidden>)
 >Re: How a window was closed? (From: Jens Alfke <email@hidden>)
 >Re: How a window was closed? (From: Eric Gorr <email@hidden>)
 >Re: How a window was closed? (From: Jens Alfke <email@hidden>)
 >Re: How a window was closed? (From: Eric Gorr <email@hidden>)
 >Re: How a window was closed? (From: Graham Cox <email@hidden>)
 >Re: How a window was closed? (From: Eric Gorr <email@hidden>)

  • Prev by Date: Re: Uninitialized rectangle??
  • Next by Date: Re: Uninitialized rectangle??
  • Previous by thread: Re: How a window was closed?
  • Next by thread: Re: How a window was closed?
  • Index(es):
    • Date
    • Thread