Saving TextArea

Hello,

I used this code for saving text in a Textarea in Carbon but it does not work in Cocoa

If MyTextArea.Save(document, True) then
end if

What is the Cocoa equivalent?

Thanks.

Lennox

Check the docs. It says it’s deprecated and there is a link to StyledText.RTFData with an example how to save text as file.

Thanks Eli,

That seems quite a task.

I am a bit confused here…
So, if the user do some markups in a textarea how would I know where and what the markups are in order code for them to be saved?

Or am I missing something?

Thanks.

Lennox

That .RTFdata contains ALL the info (text and style) in the same way as .text contains all the text.

No need to deal with each change when you can just save everything.

From http://documentation.xojo.com/index.php/StyledText.RTFData

Dim f as FolderItem=GetSaveFolderItem(TextTypes.TextRtf,"TestSaveRTF") If f <> nil then Dim s as TextOutputStream=TextOutputStream.Create(f) s.Write TextArea1.StyledText.RTFData s = nil End if

P.S I think you might have missed that StyledText is a class, not a string, so it does not end with TextArea.StyledText but continues with .RTFdata (which is a string)

Example here Post 83925

Thanks Axel,

Just downloaded it and it seems to do what I want.

Thanks again.

Lennox