RE: Multiple Toolbars, Same Window like XCode
RE: Multiple Toolbars, Same Window like XCode
- Subject: RE: Multiple Toolbars, Same Window like XCode
- From: Keith Blount <email@hidden>
- Date: Wed, 1 Mar 2006 07:31:20 -0800 (PST)
Not sure if this would work, but...
Instead of having separate toolbars that you swap
around, have you tried setting up your delegate
methods so that they return different toolbar item
identifiers depending on the mode? Something like:
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar
*)toolbar
{
if ( mode == firstModeTag)
{
return [NSArray
arrayWithObjects:someIdentifiersHere,nil];
}
else if (mode == secondModeTag)
{
return [NSArray
arrayWithObjects:someOtherIdentifiersHere,nil];
}
// etc
}
// And the same for -toolbarDefaultItemIdentifiers:
I've never tried this out myself and it may completely
fail, but it might be worth a shot...
All the best,
Keith
--- ORIGINAL MESSAGE ---
[ Sorry - forgot to label the thread with a subject! ]
List:
I'm trying to create a document window with one
toolbar for each
of its major modes, like XCode. I've approached the
problem by
creating (and retaining) two different toolbar
instances. I
implemented the basic delegate methods, providing a
different set of
allowed / default item identifiers depending on the
toolbar. I swap
the toolbars using [window setToolbar:toolbar]; when
the document's
mode changes.
The problem is that, in certain circumstances, the
following error
occurs while swapping the toolbar (but not on the
setToolbar: line,
this is somewhere in the Cocoa frameworks):
*** NSRunLoop ignoring exception '*** -[NSCFArray?
addObject:]:
attempt to insert nil' that raised during posting of
delayed perform
with target 550a0f0 and selector
'_doDelayedValidateVisibleToolbarItems'
At this point, the toolbar that was switched to is
missing items
where it wasn't before. It's important to note
(because I think this
may be part of - if not all of - the problem): Both
toolbars share
some items - and the shared items are the ones that
stay during the
erroneous swap while the non-shared ones are the ones
that disappear.
I'm thinking this is some problem with the
auto-saving behavior.
Looking in the cocoa-dev list archives, I found a
reference to such a
problem with a solution that worked by disabling the
auto-save. The
problem is, I want the user to be able to customize
each toolbar with
persistence.
When I posted this on cocoadev.com, it was
suggested that I create
a dictionary to retain the toolbaritems. I tried that
and got the
same error after switching between toolbars several
times. I then
told the method above to return [item copy]; (ignoring
the memory
leak for now. That error went away, but now any
toolbars not
currently displayed when the window is resized produce
drawing errors
when you switch back to it after a resize.
Has anyone done this before? What am I missing? Any
insight as to
how XCode might be accomplishing this? Are they using
private APIs?
Any help is most appreciated. Thanks!
--
I.S.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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