http://www.newton-inc.com/dev/techinfo/qa/qa.htm
clEditView
every time some change is made, typing is very slow. So, when should it be saved?AddDelayedCall
or AddDelayedSend
can be used. The OS also provides AddProcrastinatedSend
and AddProcrastinatedCall
, which more or less implement the timer-resetting feature for you.viewIdleScript
. The viewIdleScript
is preferred over AddProcrastinatedCall/Send
because of better management of the event queue by the OS. When you call SetupIdle
to start an idle timer, any existing idle timer is reset. Procrastinated calls/sends aren't currently implemented by resetting an existing timer, but rather by creating a delayed event which fires for each call and then checking a flag when the timer expires to see if it's the last one.target
frame, which is usually a soup entry. The entry layer implements StartFlush
to start the timer, and EndFlush
is called when the timer expires and which should ensure that the data is saved to the soup.StartFlush
equivalent could be implemented something like this: StartFlush: func()
begin
self.entryDirty := TRUE;
:SetupIdle(5000); // 5 second delay
end;
viewIdleScript
would look something like this: viewIdleScript: func()
begin
:EndFlush();
nil; // return NIL to stop the idler until next StartFlush
end;
EndFlush
equivalent would look something like this: EndFlush: func()
if self.entryDirty then
begin
// getting data from editView may not
// be necessary at this point
myEntry.editViewData := <editView/self>.viewChildren;
EntryChangeXmit(myEntry, kAppSymbol);
self.entryDirty := nil;
end;
EndFlush
as a separate method rather than just putting the contents in the viewIdleScript
makes it easy to call the method from the viewQuitScript
or viewPostQuitScript
, to guarantee that changes are saved when the view is closed. (The viewIdleScript
may not have been called if the user makes a change then immediately taps the close box or overview or whatever.)