2

I'm having a weird problem receiving any messages from an NSFontPanel when an NSTextField in my app is focussed.

Even a subclass of NSTextField doesn't receive anything from the font panel.. it seems that everything sent by the panel e.g. when changing fonts, colors, etc. is just eaten somewhere in AppKit.

All works fine when the text field is not focussed, i.e. I'm getting the usual changeFont: and related messages.

Also, unlike in NSTextView there doesn't appear to be any kind of property to toggle font panel support on/off in an NSTextField..

Any hints much appreciated!

ATV
  • 4,116
  • 3
  • 23
  • 42
  • 1
    The text field will get an `NSTextView` when the users enters text (see **Text Fields, Text Views, and the Field Editor**, https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/TextFieldsAndViews/TextFieldsAndViews.html). You might want to replace it with a custom class to get the messages font manager sends to the active delegate. – Jay Jan 23 '16 at 16:28

1 Answers1

2

The messages are eaten by the NSTextView cell of the NSTextField. The property to toggle rich text is allowsEditingTextAttributes or "Rich Text" in the xib.

Willeke
  • 14,578
  • 4
  • 19
  • 47
  • Thanks - though toggling `allowsEditingTextAttributes` just results in the text field responding to the font panel, I'm still not getting to the font panel. I need to apply the font from the font panel to the text field in modified form so can't just have it talk directly to the text field. – ATV Jan 21 '16 at 17:40
  • You can use a subclass of NSTextView. [How to Substitute a Custom Field Editor](https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/TextEditing/TextEditing.html#//apple_ref/doc/uid/TP40009459-CH3-SW35). – Willeke Jan 22 '16 at 10:19
  • To be precise: The `NSTextView` is the (temp.) control provided by the window when the user edits text in an `NSTextField` (see https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/TextFieldsAndViews/TextFieldsAndViews.html) – Jay Jan 23 '16 at 16:30