• 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: Best way to customize Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to customize Cocoa


  • Subject: Re: Best way to customize Cocoa
  • From: P Teeson <email@hidden>
  • Date: Tue, 14 Feb 2006 23:29:22 -0500


On 2006-Feb-06, at 5:56 PM, Daniel Jalkut wrote:

Dan:

On Feb 14, 2006, at 2:47 PM, Dan Koss wrote:

I'm looking at creating a custom UI similar to Logic Pro/Express with colored window backing, different colored buttons, etc. and possibly a skin-type functionality.

Is subclassing NSWindow the best way of achieving this, or is there a better way? And if I subclass NSWindow, do I have to overload all three init methods?

For the window background, all you have to do is call "setBackgroundColor:" on the window.


For the colored buttons, etc., you'll probably want to subclass the particular buttons you want. But since it sounds like you're going for highly customized UI, it might be easier to start from scratch and develop your own button subclass that draws everything yourself.

When you subclass something, you don't need to overload any init methods, unless you're intercepting init method parameters of to the subclass, or you need to initialize your own instance variables. In any case, you can overload whichever init method you choose, as long as you make sure it calls through to the corresponding super initializer. If your goal is to just make sure you get a chance to initialize your instance variables, you want to override the designated initializer, because it's the only one that's guaranteed to be called during initialization.

In the case of NSWindow, the designated initializer is "initWithContentRect:styleMask:backing:defer:" - you'll see that this is well documented in the NSWindow class documentation.

For more on initializers:

http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaObjects/Articles/ObjectCreation.html

Daniel

Not wanting to be too pedantic but, given the following definitions, maybe you mean override?


Overloading a method refers to having two methods which share the same name but have different signatures.
Overriding a method refers to having a new implementation of a method with the same signature in a subclass.


respect....
Peter
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Best way to customize Cocoa
      • From: Dan Koss <email@hidden>
    • Re: Best way to customize Cocoa
      • From: Dan Koss <email@hidden>
References: 
 >Best way to customize Cocoa (From: Dan Koss <email@hidden>)
 >Re: Best way to customize Cocoa (From: Daniel Jalkut <email@hidden>)

  • Prev by Date: Re: plain white boxes/views
  • Next by Date: Help in diplaying line width
  • Previous by thread: Re: Best way to customize Cocoa
  • Next by thread: Re: Best way to customize Cocoa
  • Index(es):
    • Date
    • Thread