我正在創建一個NSFontPanel
,但選擇字體不會調用changeFont:
方法。爲什麼不是changeFont:從我的NSFontPanel被調用?
我有一個NSWindowController
子類定義了這些方法:
- (IBAction)showFontPanel:(id)sender {
[[NSFontPanel sharedFontPanel] makeKeyAndOrderFront:self];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSFont *theFont = [NSFont fontWithName:[prefs stringForKey:iepFontName] size:[prefs floatForKey:iepFontSize]];
[[NSFontPanel sharedFontPanel] setPanelFont:theFont isMultiple:NO];
[[NSFontManager sharedFontManager] setDelegate:self];
}
- (void)changeFont:(id)sender {
NSLog(@"changeFont");
}
- (NSUInteger)validModesForFontPanel:(NSFontPanel *)fontPanel {
return NSFontPanelFaceModeMask | NSFontPanelSizeModeMask | NSFontPanelCollectionModeMask;
}
字體面板出現在validModesForFontPanel:
啓用了正確的字體和選定的尺寸,只有模式,但是當我選擇不同的字體,changeFont:
方法不會被調用。我的理解是changeFont:
動作消息被髮送到響應者鏈。作爲一個測試,我在我的應用程序委託中(它應該在響應者鏈中)放置了一個相同的changeFont:
方法,但它也沒有被調用。我在某個地方錯過了一步嗎?