Re: Actions cancelled by application close

From: [at]} <gruntz{>
Date: Mon, 23 Aug 1999 13:09:53 +0200

> The problem is this: if the user closes the application before the task has
> finished, data may be lost and the external device may be left in an
> undefined state. If the user tries to close the application, I would like
> some way of prompting the user, and cleaning up afterwards if they confirm
> that the task is to be cancelled.

You can install a Notifier for any Sequencer. Sequencers are those objects which
keep track of the undo/redo stack. If a window is closed, a ColseMsg is sent to
any registered Notifier. Sequencer objects are registered with a domain and generated
when a window is opened. Thus, if you have a process specific window (e.g. a window
which displays the progress of your task), then you can associate your MayCancel
procedure with the sequencer of this window:

     PROCEDURE (n: Notifier) Notify (VAR msg: Sequencers.Message);
          VAR res: INTEGER;
     BEGIN
          WITH msg: Sequencers.CloseMsg DO
               Dialog.GetOK("A data transfer is still in process. Do you want to abort the task ?", "", "", "",
                                            {Dialog.yes, Dialog.no}, res);
               msg.sticky := res = Dialog.no
      ELSE
      END
 END Notify;

If the window is actually removed, you get a Sequencers.RemoveMsg and can do
the cleaup there.

How to access the Sequencer of a document which is opened in a window?
a) You can either go over the domain of a view displayed in the document. This domain
is actually a Sequencer: s := v.domain(Sequencers.Sequencer)
b) If you have access to the window of type Windows.Window, the sequencer is stored
in the seq field.

- Dominik

--------------------------------------------------------------
Dr. Dominik Gruntz
Oberon microsystems, Inc., Technoparkstrasse 1, CH-8005 Zurich
gruntz{([at]})nowhere.xy
tel ++41-1-445-1751
fax ++41-1-445-1752



To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy
Received on Mon Aug 23 1999 - 14:03:41 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:27:43 UTC