http://www.newton-inc.com/dev/techinfo/qa/qa.htmMakeTextNote function.protoTXView. Use the protoTXView methods to add data to that view. When done, use the Externalize method to get the data in a form suitable for saving in the Works soup.protoTXView, it's imperative that you call the SetStore method so that the data is created on the user store rather than the NS heap. Different formats are used for store-backed and heap-backed protoTXViews, and the type of backing is carried into the Externalized data. As a result, failure to use SetStore would cause you to create a Works document that was not backed by the user store and which could eventually result in out-of-memory errors when the user added sufficient data to the document.SetStore in the viewSetupFormScript and AdoptEntryFromStationery, or the intial text specified in the 2nd paramater to Replace. (Notably, you may wish to provide styles for the text, see the Newton 2.1 OS documentation on the protoTXView method Replace.) // create and populate a dummy protoTXView
local textView := BuildContext(
{
_proto: protoTXView,
viewBounds: SetBounds(0, 0, 0, 0),
viewFlags: 0,
ReorientToScreen: ROM_DefRotateFunc,
viewSetupFormScript: func() begin
inherited:?viewSetupFormScript();
self:SetStore(GetDefaultStore());
end,
});
textView:Open();
textView:Replace({first: 0, last: 0}, {text: "Some initial text"}, nil);
// get the data in an external form for the Works soup
local saveData := textView:Externalize();
textView:Close();
// Create a new Works document from the data
GetRoot().NewtWorks:AdoptEntryFromStationery(
{
title: "Initial Title",
saveData: saveData,
hiliteRange: {first: 0, last: 0},
margins: {top: 72, left: 72, right: 72, bottom: 72},
}, 'paper, GetDefaultStore());