Re: NSToolbar delegate -toolbarAllowedItemIdentifiers:

2014-02-08 Thread Markus Spoettl

On 2/8/14 12:25 AM, Quincey Morris wrote:

It’s a while since I had to suffer through the pain that is NSToolbar delegate
methods, but I suspect the problem is that the IB-created items are in a
different universe from programmatically created ones. Therefore, in a “mixed”
configuration, ‘toolbarAllowedItemIdentifiers:’ is queried only to supply the
identifiers of non-IB items that you want to add to the IB-defined toolbar. The
delegate method is, after all, optional *in this case*.

If that’s correct, and you have a toolbar whose items are allowed in a
*contextually* dependent way, you’ll have to create the toolbar contents
programmatically — or at least those items.

Note that I’m speculating. I vaguely recall that there was something very
horrible about mixing IB and non-IB items, and this may or may not be it.


Yes, horrible comes to mind.

I ended up duplicating the entire toolbar so it's constructed at runtime - with 
embedded segmented controls that's a lot of fun. That was only way to make it work.


Unfortunately I can't even use the same toolbar identifier (for 
auto-configuration saving purposes), because even though 
-toolbarAllowedItemIdentifiers: returns a reduced set, NSToolbar will 
reconstruct items with identifiers not currently allowed when restoring a 
toolbar configuration that was stored when all items were allowed.


Regards
Markus
--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbar delegate -toolbarAllowedItemIdentifiers not getting called, other delegate methods are

2014-02-07 Thread Markus Spoettl

On 2/7/14 10:31 PM, Markus Spoettl wrote:

Hi,

   I have a strange problem with a toolbar that is configured in IB which I need
to adjust programmatically. It has a delegate set (to the window controller) but
for some reason

- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar

is never getting called. Other delegate methods such as

- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar

are getting called. I need to adjust (restrict) the allowed items under certain
circumstances and there's no other way to do that.


Of course I spoke too soon. It is called, but it doesn't seem to change what 
NSToolbar is doing. It is called when I open the toolbar customization, but even 
though I return a restricted set of identifiers, it still presents all items 
that were set up in IB, not the reduced set of items as it's supposed to present.


So the question is: How do I remove an item with a given identifier in such a 
way that it does not appear in the customization, neither is single item nor as 
part of the default toolbar configuration.


Thanks for any pointers!

Regards
Markus
--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbar delegate -toolbarAllowedItemIdentifiers:

2014-02-07 Thread Jerry Krinock
I’ve never used -toolbarAllowedItemIdentifiers:.  However, its documentation 
states…

Sent to discover the allowed item identifiers for a toolbar.”

Wonderful :))  There is no indication of who sends it, when, nor what is done 
with the result.  The “Discussion” is no more enlightening either.  Therefore I 
have no idea what the purpose of this method is.  Apparently, based on your 
results, its purpose is not your purpose.

On 2014 Feb 07, at 13:43, Markus Spoettl ms_li...@shiftoption.com wrote:

 So the question is: How do I remove an item with a given identifier in such a 
 way that it does not appear 

Here is how I remove toolbar items that are present in nibs…

NSInteger someToolbarItemIndex = [[toolbar items] 
indexOfObject:someToolbarItem] ;
if ((someToolbarItemIndex = 0 )  (someToolbarItemIndex  [[toolbar items] 
count]))
{
[toolbar removeItemAtIndex:settingsToolbarItemIndex] ;
}

where ‘toolbar’ and ‘someToolbarItem’ are outlets, connected in the nib.  So a 
disadvantage of my method is that you need an outlet for any removable toolbar 
item.  But I have only have one, and it works for me.

 in the customization, neither is single item nor as part of the default 
 toolbar configuration.

I hope that clause was not important because I don’t understand it.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbar delegate -toolbarAllowedItemIdentifiers:

2014-02-07 Thread Markus Spoettl

On 2/7/14 11:19 PM, Jerry Krinock wrote:

I’ve never used -toolbarAllowedItemIdentifiers:.  However, its documentation 
states…

Sent to discover the allowed item identifiers for a toolbar.”

Wonderful :))  There is no indication of who sends it, when, nor what is done 
with the result.  The “Discussion” is no more enlightening either.  Therefore I 
have no idea what the purpose of this method is.  Apparently, based on your 
results, its purpose is not your purpose.

On 2014 Feb 07, at 13:43, Markus Spoettl ms_li...@shiftoption.com wrote:


So the question is: How do I remove an item with a given identifier in such a 
way that it does not appear


Here is how I remove toolbar items that are present in nibs…

NSInteger someToolbarItemIndex = [[toolbar items] 
indexOfObject:someToolbarItem] ;
if ((someToolbarItemIndex = 0 )  (someToolbarItemIndex  [[toolbar items] 
count]))
{
 [toolbar removeItemAtIndex:settingsToolbarItemIndex] ;
}

where ‘toolbar’ and ‘someToolbarItem’ are outlets, connected in the nib.  So a 
disadvantage of my method is that you need an outlet for any removable toolbar 
item.  But I have only have one, and it works for me.


in the customization, neither is single item nor as part of the default toolbar 
configuration.


I hope that clause was not important because I don’t understand it.


It is important, I'm afraid. Removing the items from the toolbar is not a 
problem. However, I can't get the toolbar to remove them from the customization 
sheet.


I thought the whole point of telling the toolbar which of the items are allowed 
is that those items will not be shown them during customization (or anywhere 
else). The -toolbarAllowedItemIdentifiers: delegate method is called at the 
beginning of the customization (before the sheet comes up), that's a hint that 
it's used for a purpose that has to do with customization. But apparently its 
result is ignored because items that are disallowed (by not returning them in 
this delegate method) are still visible.


Regards
Markus
--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbar delegate -toolbarAllowedItemIdentifiers:

2014-02-07 Thread Quincey Morris
On Feb 7, 2014, at 14:49 , Markus Spoettl ms_li...@shiftoption.com wrote:

 But apparently its result is ignored because items that are disallowed (by 
 not returning them in this delegate method) are still visible.

It’s a while since I had to suffer through the pain that is NSToolbar delegate 
methods, but I suspect the problem is that the IB-created items are in a 
different universe from programmatically created ones. Therefore, in a “mixed” 
configuration, ‘toolbarAllowedItemIdentifiers:’ is queried only to supply the 
identifiers of non-IB items that you want to add to the IB-defined toolbar. The 
delegate method is, after all, optional *in this case*.

If that’s correct, and you have a toolbar whose items are allowed in a 
*contextually* dependent way, you’ll have to create the toolbar contents 
programmatically — or at least those items.

Note that I’m speculating. I vaguely recall that there was something very 
horrible about mixing IB and non-IB items, and this may or may not be it.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com