September 8, 2002 - Implementing the OnMouseUp Event Handler | WebReference

September 8, 2002 - Implementing the OnMouseUp Event Handler

Yehuda Shiran September 8, 2002
Implementing the OnMouseUp Event Handler
Tips: September 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Suppose you want to override the OnMouseUp event within a certain panel of the docking windows application. First, you need to define the new overriding class:

  class ClickPanel extends System.Windows.Forms.Panel {
    override protected function OnMouseUp (e : MouseEventArgs) {
      super.OnMouseUp(e);
      MessageBox.Show("Mouse Up at: "+e.X+", "+ e.Y);
    } 
  } 
Then, you need to change the top panel to behave as the ClickPanel class, instead of the generic Panel class. We first change its definition:

  private var topPanel: ClickPanel;
And then we need to change its construction statement:

  topPanel= new ClickPanel;
You pop up the window by calling the Application.Run() method. If the package name is say MouseUpPkg and the class name is MouseUpCls, the running statement is:

  Application.Run(new MouseUpPkg.MouseUpCls());
Whenever you click inside the top panel, a message box will pop up with the event coordinates, like this:

To learn more about JScript .NET and ASP.NET, go to Column 117, JScript .NET, Part XI: Creating Windows Forms.