Skip to content

Instantly share code, notes, and snippets.

@nickludlam
Created January 6, 2013 16:00
Show Gist options
  • Save nickludlam/4468122 to your computer and use it in GitHub Desktop.
Save nickludlam/4468122 to your computer and use it in GitHub Desktop.
A MacRuby subclass of NSWindow which will fade away when closed
class FadeWindow < NSWindow
def fadeInAndMakeKeyAndOrderFront(orderFront)
self.setAlphaValue(0);
if orderFront
self.makeKeyAndOrderFront(nil)
end
self.animator.setAlphaValue(1.0)
end
def fadeOutAndOrderOut(orderOut)
if orderOut
delay = NSAnimationContext.currentContext.duration + 0.1
self.performSelector('orderOut:', withObject:nil, afterDelay:delay)
end
self.animator.setAlphaValue(0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment