Pages

Sunday, January 13, 2013

Resign from being the first responder for the NSFontmanager

Hi All,

 

I have preference window ( accessed thruough preferences menu) where I let the user set the font and color for text displayed in my main window. This all works fine, as I have overidden the ChangeFont method.  Here is the code I have used:

 

    // request to display the font panel, received from the preference window

- (IBAction)displayFontPanel:(id)sender{

   

    NSFontManager *fontManager = [NSFontManager sharedFontManager];

             

    NSFontPanel *fontPanel = [fontManager fontPanel:YES];

    [fontManager setTarget:self];

    [fontPanel makeKeyAndOrderFront:sender];   

}

 

    // font change : received when font is changed in the preference window

- (void)changeFont:(id)sender {

     

    titleFont = [sender convertFont:titleFont];

    [self UpdatePrefWindow :titleFont];

    [self appPreferences:updatePlist];

}

 

The issue  now is that all other text fields and text views in my main window are not able to receive the changeFont message. What I am trying to do is to resign from being the first responder once the preference window is deactivted and become the first responder again when it is achitvated.  Any ideas.

 

Thanks

 

Rashid


View the original article here

0 comments:

Post a Comment