Re: Custom Controls Where to start
Re: Custom Controls Where to start
- Subject: Re: Custom Controls Where to start
- From: Sandro Noël <email@hidden>
- Date: Thu, 26 Nov 2009 19:01:17 -0500
Thank you Alastair.
Well it's pretty complicated, This is my third application, the first being Bonjour Mounter, the Second RDP Launcher.
Others were created but never released. I've always used the OS's controls but now I find myself frustrated
with the limits of these controls in terms of looks. I see other application makers producing great looking
applications with custom looking views and controls.
So I want to be able to know where to start and what to think about when I create a control, a view.
I did venture to read the Doc documentation, there is much there but so much it becomes confusing.
for example, the look of the segment control does not fit the look that i'd like it to have, i find it's a good enough starting point
to create a tab bar, a little like Safari, and add the close tab button and some status information on the right end of the tab.
along with a scrolling title like on the Apple TV.
From what I understand, all I would have to do is create my own cell.
Also, the controls for the HUD panels are missing, there is BWHUDAppKit.framework that does partial of the work witch is amazing.
but it is not complete, i like to use the CollectionView control, and it hans not been implemented, so i'm off to do it myself.
there are also table cels missing, i would like to create those too.
I think that once I've done these I would pretty much be able to create my own out of this world looking controls while preserving HIG intact.
and it will also give me a better understanding of the underpinnings of cocoa.
I also want to write a control/view that incorporates some of the features of most code editors, code folding, code colouring and such out of the box.
but that is not for now.
Sandro.
On 2009-11-26, at 5:20 PM, Alastair Houghton wrote:
> On 26 Nov 2009, at 18:22, Sandro Noël wrote:
>
>> I'm trying to educate myself on how to create my custom controls/Views.
>> Everywhere i look no one uses the same methods to override drawing and behaviour.
>> and most of the example do not start from the same place,
>
> :-) There are, as you have noticed, several approaches that work, depending on what you're doing and what you hope to achieve.
>
>> Some start from NSControl with a combination of NSCell and NSActionCell
>
> Yep.
>
>> Others Start from NSView, and some start from Apple's controls and override the drawing.
>
> Yep.
>
>> What i am trying to achieve is
>> 1: to be able to change the look of the controls that already exist if i need to.
>
> In which case you'll have to look how the control in question is implemented. If it's an NSControl subclass, you probably need to subclass the corresponding NSCell subclass in order to customise it.
>
>> 2: if I have the need for a control that does not exist, i want to be able to create it myself.
>> including having to respond to user input and mouse clicks and send those back to the caller ( thru delegates or actions )
>
> If it "smells like" an NSControl (e.g. a button or something), then using a custom cell is probably the best way to go. Especially if there's already a matching subclass of NSControl (e.g. NSButton), in which case you can subclass NSButton and NSButtonCell and get most of the existing button functionality for free.
>
> If it doesn't look like that, for instance it's some new control that the system doesn't have, or it's the main document view of your app or something, then NSView is probably a better bet.
>
> NSControl and NSCell have the advantage that they do various things for you, *and* you can create an NSMatrix of your new cell class, or stick it into an NSTableView.
>
> If you're using a custom NSView, it's harder to put it into a table view, and you have to handle everything directly yourself, but, on the other hand, you only have to write one class and it's perhaps slightly more apparent how to handle e.g. mouse events than it is with NSCell (I know that's something I struggled with at first).
>
> I'll also add a warning. While you can create custom controls, it's important to consider carefully whether they're necessary. Making controls that look or work in a manner that doesn't match those in the HIG is probably a mistake, unless you have a good justification for it (and "looks/works like Windows", although a common justification, is wrong).
>
> If you want more specific advice, you'll have to be more specific about what you want to achieve.
>
> Kind regards,
>
> Alastair.
>
> --
> http://alastairs-place.net
>
_______________________________________________
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