spacer
Yehuda Shiran September 7, 2002
Overriding an Event Handler
Tips: September 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Sometimes you want to override an event handler of a class you inherit. Suppose you want to redefine the function OnMouseUp() of the class System.Windows.Forms.Panel, by adding a message that displays the coordinates of the event. You need to define a new class, say ClickPanel, which extends the class System.Windows.Forms.Panel. You need to:

  • Include the definition of OnMouseUp() from the super class, System.Windows.Forms.Panel
  • Add a message box that displays the coordinates of the event.

You may want to specify that the new function is overriding the super class and is protected against further overriding by other classes that may inherit it:

  override protected function OnMouseUp (e : MouseEventArgs) {
    super.OnMouseUp(e);
    MessageBox.Show("Mouse Up at: "+e.X+", "+ e.Y);
  } 
Integrating into the class ClickPanel:

  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);
    } 
  } 
To learn more about JScript .NET and ASP.NET, go to Column 117, JScript .NET, Part XI: Creating Windows Forms.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business