On 06/08/2012, at 11:20 AM, Shane Stanley <[email protected]> wrote:

> On 06/08/2012, at 10:46 AM, Graham Cox <[email protected]> wrote:
> 
>> I'm puzzled as to how the standard "Bold" text menu item works, because it 
>> too simply calls addFontTrait: (according to the action set in IB) and has a 
>> tag indicating bold. How then does it REMOVE the bold trait? Is the Font 
>> Manager manipulating the action of the menu item when it validates it? Would 
>> make sense but I can find no documentation to that effect.
> 
> How about this: "If you provide your own Font menu, you should register it 
> with the font manager using the setFontMenu: method. The font manager is 
> responsible for validating Font menu items and changing their titles and tags 
> according to the selected font. For example, when the selected font is 
> Italic, the font manager adds a check mark to the Italic Font menu item and 
> changes its tag to UnitalicMask. Your Font menu’s items should use the 
> appropriate action methods and tags, as shown in Table 6-4." 
> 
> Search for "Customizing the Font Conversion System".


Thanks, that's useful.

The way this has been implemented seems a bit weird to me, but we'll have to 
live with it. It means adding additional controls (e.g. toolbar buttons) to 
duplicate some of the features of the text menu is difficult, because the text 
menu is being given special treatment by the Font Manager.

I have found a solution that works though it has a strong feeling about it that 
it's a smelly hack. I have my own controller that handles the buttons and 
interacts with the Font Manager and the selected text objects by pretending to 
be the Font Manager in a controlled manner, and implementing things like 
-convertFont: itself. That way it gets a chance to peek at the font traits that 
need to be toggled and can invoke the relevant method (add or remove trait) as 
needed.

If anyone can think of a more elegant solution I'm interested.

--Graham



_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to