Re: Problem with custom control in NSToolbar
Re: Problem with custom control in NSToolbar
- Subject: Re: Problem with custom control in NSToolbar
- From: Laurent Daudelin <email@hidden>
- Date: Tue, 08 Jun 2004 10:20:33 -0400
On 08/06/04 10:09, "Chris Giordano" <email@hidden> wrote:
>
Laurent,
>
>
I haven't seen a response from one of the more knowledgeable members of
>
the list yet, so...
>
>
On Jun 7, 2004, at 4:54 PM, Laurent Daudelin wrote:
>
>
> Hi all!
>
>
>
> I have a problem which had me pulling my hairs for the last couple of
>
> days.
>
> I finally decided to ask here for help before I no longer have hairs
>
> to pull
>
> out!
>
>
>
> Basically, I took the "ImagePopUpButton" class from
>
> <http://iratescotsman.com/products/source/> to use it in a toolbar.
>
> This is
>
> a subclass of NSPopUpButton that reproduces the behavior of popup
>
> toolbar
>
> items in Xcode, for example.
>
>
>
> After making some additions to the code (NSCoding protocol since
>
> NSToolbar
>
> seems to encode some items at some point), the popup button works fine.
>
> However, when I choose to customize the toolbar, the icon doesn't show
>
> up in
>
> the customization palette. Only the title. If I remove the current
>
> item from
>
> the toolbar, then drag the one from the palette, it will appear
>
> immediately.
>
> I've checked everything I could think of, be it the min size of the
>
> toolbar
>
> item and its max size, the cellframe where the custom cell is
>
> displaying
>
> those icons, I can't for the life of me finding what is missing.
>
>
>
> Anybody has any idea or ran into a similar issue? Code is available
>
> upon
>
> request to <mailto:email@hidden>.
>
>
>
>
How are you returning the toolbar item in
>
toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:? There was
>
some discussion a month or so back (see the thread "Subclassing
>
NSToolbar is *almost* really good") in which the same kind of issue was
>
happening. The fix there was to be sure to return a copy (i.e.,
>
[toolbarItem copy]) of the toolbar item in this method. Even creating
>
a new toolbar item and setting the view to be identical to the source
>
doesn't entirely work -- it has similar odd results (in the test code
>
I'm looking at, it usually disappears from the toolbar when the
>
customization palette is displayed). My guess is that creating a copy
>
of the view would work, but I'm not really in a position to test that
>
out right now.
>
Hi Chris!
I thought about that. Initially, I was always returning the same instance,
but now, I'm creating a new one every time I'm asked for it, using a
dictionary to hold the attributes. I did put a few NSLog() here and there
and I know that 3 different instances are created when I run the
customization palette, and the drawCellInFrame: is also called for each on
these instances. The only thing I haven't duplicated in my encodeWithCoder:
and initWithCoder: (which is used by the toolbar apparently), are the images
used to draw the icons, but I thought that a single image was shared anyway
no matter how often it would be requested.
I'll check it out this thread, although it didn't show up in the various
searches I did in the archive before posting.
Thanks for the reply!
-Laurent.
--
========================================================================
Laurent Daudelin Developer, Multifamily, ESO, Fannie Mae
mailto:email@hidden Washington, DC, USA
************************ Usual disclaimers apply ***********************
_______________________________________________
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.