• 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: Fading in windows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fading in windows


  • Subject: Re: Fading in windows
  • From: Eric Czarny <email@hidden>
  • Date: Tue, 27 Apr 2004 00:11:52 -0400

I wrote a subclass of NSWindowController that uses the following two
methods to handle the fading in of windows. For those of you who have
examined the FadeTest example you'll notice that making a window fade
out is nothing more than modifying a few lines of code to get it to
work the way you want.

Note: _timer is an instance variable and that -(void)showWindow:
(id)sender is sent to NSWindowController to display a window. I am sure
there is a better way to do this, but it works rather well for the time
being.

- (void)showWindow: (id)sender
{
NSWindow *window = [self window];

if ([window alphaValue] == 1.0)
{
[[self window] setAlphaValue: 0.0];
}

_timer = [[NSTimer scheduledTimerWithTimeInterval: 0.05 target: self
selector: @selector(fadeInWindow:)
userInfo: nil repeats: YES] retain];

[super showWindow: sender];
}

- (void)fadeInWindow: (NSTimer *)timer
{
NSWindow *window = [self window];

if ([window alphaValue] < 1.0)
{
[window setAlphaValue: ([window alphaValue] + 0.1)];
}
else
{
[_timer invalidate];
[_timer release];
}
}

However, I was wondering, how could I fade out every window upon
termination of the application? What I have now will only fade out the
window when the user explicitly closes a window that uses my
NSWindowController subclass as its window controller subclass.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Fading in windows
      • From: Jim Witte <email@hidden>
  • Prev by Date: Re: NSOpenPanel and JPG files
  • Next by Date: Re: NSBezierPath containsPoint question
  • Previous by thread: Re: Fading in Windows
  • Next by thread: Re: Fading in windows
  • Index(es):
    • Date
    • Thread