• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Bug with -changeAttributes: in NSFontManager/Font Panel?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug with -changeAttributes: in NSFontManager/Font Panel?


  • Subject: Bug with -changeAttributes: in NSFontManager/Font Panel?
  • From: Graham Cox <email@hidden>
  • Date: Sat, 13 Sep 2008 12:16:47 +1000

I'm using the Font Panel via NSFont Manager to change text attributes through a modal panel (in fact a sheet).

I can change the font OK, as using -setTarget: I can set the target of the font manager to my modal panel. However, I never get the call to - changeAttributes:, so all the stuff such as colour and shadow that the Font Panel has doesn't function.

Is this a bug, or am I doing something wrong? If it is a bug, can anyone suggest a workaround?

My code is pretty simple:

When my modal sheet is initialized, I set up the font manager thusly:

// establish the connection to the font panel and update it to match the current font/text attributes

NSDictionary* textAttributes = [settings objectForKey:kDKOMapGridHorizontalAnnotationTextAttributes];
NSFont* font = [textAttributes objectForKey:NSFontAttributeName];

[[NSFontManager sharedFontManager] setTarget:self];
[[NSFontManager sharedFontManager] setSelectedAttributes:textAttributes isMultiple:NO];
[[NSFontManager sharedFontManager] setSelectedFont:font isMultiple:NO];


(where 'settings' is a dictionary of a whole raft of things, including the text attributes of the text I want to change via the font panel)

and my -changeFont: and -changeAttributes: methods look like:

- (IBAction)		changeFont:(id) sender
{
	// received changeFont message from font panel

NSFont* newFont, *oldFont;
NSMutableDictionary* textAttributes = [[mSettings objectForKey:kDKOMapGridHorizontalAnnotationTextAttributes] mutableCopy];

oldFont = [textAttributes objectForKey:NSFontAttributeName];
newFont = [sender convertFont:oldFont];

[textAttributes setObject:newFont forKey:NSFontAttributeName];

[mSettings setObject:textAttributes forKey:kDKOMapGridHorizontalAnnotationTextAttributes];
[mSettings setObject:textAttributes forKey:kDKOMapGridVerticalAnnotationTextAttributes];

[textAttributes release];
[self conditionallyPreview];
}



- (IBAction) changeAttributes:(id) sender
{
NSLog(@"received -changeAttributes: from <%@>", sender );

NSDictionary* textAttributes = [mSettings objectForKey:kDKOMapGridHorizontalAnnotationTextAttributes];
NSDictionary* newAttributes = [sender convertAttributes:textAttributes];

[mSettings setObject:newAttributes forKey:kDKOMapGridHorizontalAnnotationTextAttributes];
[mSettings setObject:newAttributes forKey:kDKOMapGridVerticalAnnotationTextAttributes];
[self conditionallyPreview];
}



The call to changeAttributes is never logged.

It seems as if [NSFontManager setTarget] applies only to the changeFont: message and not to changeAttributes:. This appears to be a bug, but there may be some good reason for it. Workaround?

tia,


Graham

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Bug with -changeAttributes: in NSFontManager/Font Panel?
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Newb: Targeting an instance of a class instantiated by a NIB file
  • Next by Date: Re: Newb: Targeting an instance of a class instantiated by a NIB file
  • Previous by thread: Re: Core Data, Bindings, NSSearchField, and NSPopUpButton
  • Next by thread: Re: Bug with -changeAttributes: in NSFontManager/Font Panel?
  • Index(es):
    • Date
    • Thread