HyperView2.959 bannerDocumentation
 
public class Abort extends Dispatch

Abort.class is a special Dispatch.class object that causes the current display stack frame to abort.
In doing so the current display stack is destroyed and the View will return to Display Stack #1.
If the View is already at Display Stack Frame #1. then the Abort.class does nothing unless there is
a Gob attached to it in which case it will flag the attached Gob for removal from the View.


Methods:

Abort.class has no useful public methods.
An Abort.class is normally created and then
attached to a Gadget.class


Constructors:

Abort(HyperView);
Create an Abort,class Dispatch,class.

Abort(HyperView,Gob)


Create an Abort.class Dispatch object. When the Abort is activated, it will also flag
the Gob to be removed from the View.  If you are not at Display Stack #1, then this is
unnecessary as it the Gob will be removed automatically when any Display Stack above #1 is
aborted.




Note:
ViewMain IS "Display Stackframe #0"
Thus the first Gadget advances the stack frame
by invoking the Dispatch.begin method when the
appropriate Gadget is clicked on, and the Abort.class
(Which extends Dispatch) is invoked to abort the
display stack frame and restore the previous one.


The procedure is:

1) Create a ViewMain.class
2) Create a Gadget to call the Dispatch

3) Create the Dispatch to add to the Gadget
 
// When the Gadget is clicked on
// the HyperView calls the Dispatch.run() method
//Which:
4) Create a Gadget.class
5) Create an Abort.class
6) attach the Abort.class to the Gadget.class
7) calls HyperView.runView() to run the view

//Note:
// The Dispatch (myDispatch) runs when you click on myGadget.
// By the time the Dispatch.run method is called the previous stack frame
// has already been backed up and erased and running in the next stack frame.

// Because "myDispatch" is an "inner class" it can call the parent classes
// methods directly as long as there is no namespace collision between the
// outer and inner classes.  In this case we call the HyperView.runView()
// method which is not part of the Dispatch class but a method of the
// outer class which in this case is ViewMain which extends HyperView
// thus MyDispatch.class can call the HyperView.runView() method directly.

Note To compile and run:
   Save this example in the main HyperView
directory. www/HyperView299 as "ViewMain.java"
CD to that directory and run the compile script.
(compilef.bat) and to run the run script "run.bat"



public class ViewMain extends HyperView
{

public boolean main()
{
      // Create Gadget button at 100 X, 100 Y
Gadget myGadget       = new Gadget(" Click to Dispatch ",235,58);
MyDispatch myDispatch = new MyDispatch();   // Create a Dispatch handing it "this" (HyperView)
   myGadget.addDispatch(myDispatch);
   myGadget.gobFlags |= GOB_ON_DISPLAY;    // Set the Gob display enable bit
   setTitle("ViewMain");
   return true;
}

// Note: this is an "inner class"
// This is the Dispatch Object that runs when you click on "myGadget"

class MyDispatch extends Dispatch
{

public boolean run()
{
  
// Create a new Abort Object.
Abort myAbort      = new Abort();
      // Create a button to click on
Gadget abortGadget = new
 Gadget(" Click to abort ",241,58);
      // Create a Dispatch to add to Gadget.
   abortGadget.addDispatch(myAbort);
      // Enable the Gob.
   abortGadget.gobFlags |= GOB_ON_DISPLAY;
      // Set the title in titlebar.
  setTitle("Running in Dispatch");
  return runView();  // Will now run till aborted by
                     // an Abort.class object
                     // When you return from the
                     // the run() method,the previous
                     // stack frame is restored.
                     
}

}
}


To compile and run This example:
CD to the correct directory:
cd c:\www\HyperView299\

Compile
type:  "compilef"
Run     type :
"run"


I make the assumption that if you are using UNIX you
will know how to properly modify these scripts :)

 Screendump of program actually running

HyperView Screendump



 
Clicked on the "Click to Dispatch" button

HyperView Dispatched
                screendump