Prevent pasted font change?

Hi,
I have set my text area to use a certain font (in the inspector), but any pasted text from the clipboard overrides it, and changes the font.
I guess this is expected, but is there any way to prevent this?

If not, what is the best way to set it back to the defined font for the text area, and which is the best event to put this?

Thank you all in advance.

I think it is this property:

[quote]setAllowsEditingTextAttributes:
Controls whether the receiver allows the user to change font attributes of the receiver’s string.

@property BOOL allowsEditingTextAttributes

If YES, and the text value is an attributed string, it is displayed using the attributed string’s visual settings, which can be modified in the font panel.; if flag is NO and the text is an attributed string. the string attributes (font, color, etc.) are ignored and the string is displayed based on the text field’s settings. Setting the attributed string’s attributes are ignored when displaying the string and when the text field is editing.[/quote]

Do you use any OS X Lib extension or your own declares? A Xojo textfield does not offer access to this property without.

Ulrich,
I have macoslib in my app, but I simply set the text area’s font to Arial in the inspector.

This will not work as TextArea is an NSTextView, not an NSTextField.

Do you need declares for that?

You could just implement your own paste menu handler and paste text only.

Oh sorry, wrong control. And Christian is right – otherwise I would try setRichtext = False.

It doesn’t matter to me how I do it - so long as I can do it :slight_smile:
I have just noticed a “Styled” switch in the inspector - I think that might be what I need?

Thanks.

if you want whole textfield/textarea without style, setting it to off may work.

Yes, that’s what I did, and now it seems to be working fine :slight_smile: