HyperView2.959 bannerDocumentation
 
public class Dispatch
implements HyperConstants
A Dispatch is an intermediary between A Mouse Clicked Event and the the HyperView display lists.
These lists cannot arbitrarily change because deadlock will occur.


HyperView has 2 mechanisms for processing Mouse clicks
1) A Dispatch Object that you define and attach to the Gadget via the
   Gadget.addDispatch(myDispatch);


   Use this when you want to backup up the current view and then create a new one.
This means the entire display is erased and you may create an entire new one.
Note: The Diget a new display stack frame.



The Dispatch.class will back up the display and then the Dispatch.run()
Easy as ABC :)


A)
   //  Make a Dispatch Object for this Gadget by extending Dispatch
   // and overwriting  boolean Dispatch.run();

public class MyDispatch Extends Dispatch
{
public boolean run()   // When the gadget is clicked on
{                      // Hyperview.class calls this function
   System.out.println(" You clicked me! ");

   return true;       // You MUST return true as returning false
                      // aborts the Dispatch
}
 
B)
   // Create a Gadget currentView is the current HyperView.class reference
   // This puts it at X 100 / Y 100, and makes it 50 pixels by 50 pixels
 
 Gadget myGadget = new Gadget(currentView," Click Me! ",100,100,50,50);
 
C) Add the Dispatch.class to the Gadget.class

   myGadget.addDispatch(myGadget);

  // Thats it!   assuming you have created the Dispatch.class the sequence
  // again.

1) 
Gadget myGadget = new Gadget(currentView," Click Me! ",100,100,50,50);
2)  myGadget.addDispatch(myGadget);



 You may also override the Dispatch.class display backup/restore backup
 mechanism by setting the INHERIT_ALL bit of the Dispatch.flags variable.

    myDispatch.flags |= INHERIT_ALL;
 
After which you will advance to the next stackframe but will inherit
the entire previous stack frame.  Any Gadgets/Gobs you create will not be
destoyed when you return to the previous display stack frame. 

2)  A Lightwieght onClick() call.
You may instead create a Gob, omit using a Dispatch by overwriting 
public void Gob.onClick() method AND setting
the GOB_CLICK_METHOD bit of Gob.gobFlags.

ie:  I have an image named
"MyImage.gif"  that I use to make a Graphics Object

Remember:
A Gob is "Graphics Object" that can either be derived from an image file,
  
or rendered directly with graphics primitaves.

  
Save ViewMain.java into the SOURCE_DIR\hyperview\www\HyperView299
   SOURCE_DIR is the directory where you saved the HyperView source

B "BasicPane.class" is a Rectangular Gob.


/*
Example code:
1) Define ViewMain.class
2) Create a BasicPane by extending it.
3) Override Gob.onClick()
*/

1)
 Declare ViewMain.class which extends HyperView.class
 When ViewMain runs it is a running.



//1) Declaring ViewMain

public class ViewMain extends HyperView
{
public boolean main()
{
      // Add display setup here
   return true;
  // Always return true unless something failed.
}
}


//2) Instantiate a BasicPane.class

public class ViewMain extends HyperView
{
public boolean main()
{
      // Add display setup here
   return true;
  // Always return true unless something failed.
}
}










public void onClick()
{
   System.out.println("You clicked on this Gob!");
}