Custom view (NSSegmentedControl/NSButton) in NSToolbarItem - validate: method

  • Hi all,

    I'm new to Cocoa programming and want to develop an application with a
    Finder-like toolbar (specially, grouped buttons "backward"/"forward" in
    a NSSegmentedControl).

    I know (read in Apple Dev Doc and in mailing-lists) that :

    - I have to subclass NSView (this is already done and my custom
    view--NSSegmentedControl, is displayed in the toolbar),
    - I have to implement theses methods in my subclass :
    - (id)initWithFrame:(NSRect)frame;
    - (void)drawRect:(NSRect)rect;
    and an action method that will handle what segment has been clicked :
    - (IBAction)segControlClicked:(id)sender;

    But I have read too that :

    - many calls to the toolbarItem are forwarded to the custom view (does
    it mean that I should set the toolbarItem's target to the instance of
    my custom view and set the action to a method--segControlClicked, of
    the same instance?),
    - I should subclass NSToolbarItem to override validate: method because
    this method doesn't sent the message validateToolbarItem:(NSToolbarItem
    *)theItem to custom toolbarItem's views,
    - I should also implement every  "forwards to -view if it responds"
    methods too (ie : setTarget:, target, setAction:, action, ...)?

    Finally, that get me bored and I feel like in front of a mountain of
    code to write for a simple grouped pair of buttons :-(

    Does anybody has an experience with this?

    I've started doing lot of these stuffs but I get a problem dialing with
    the segment of the NSSegmentedControl (no highlight blue color of the
    selected segment, always the same selected segment sent whatever
    segment is clicked; ...).

    I am going to rest for while :-)

    Thanks you all (forgive my english)

    Cordialement.
    --
    Thierry Santacana - mailto:<thierry.santacana...>
    Gérant - Responsable Développements Web et Communication
    Project:Omega SARL - www.projectOmega.com - "Développer l'alternative"
    Tél/Fax : 01 60 02 76 34 - GSM : 06 63 11 67 41
    _______________________________________________
    MacOSX-dev mailing list
    <MacOSX-dev...>
    http://www.omnigroup.com/mailman/listinfo/macosx-dev