"inherited" keyword added to each time I drop a new visual component on the descendant and click to add an event.

"inherited" keyword added to each time I drop a new visual component on the descendant and click to add an event.

Delphi XE2, I've got a TFrame that's descended from a couple other TFrames. One of the parent TFrames has a few visual controls...

When I add new UI elements to the descendant form and click over to the object-inspector to add an event-handler. Each event that I add, will always get a template created with the keyword "inherited" added.

I understand the need for this, when dealing with visual-components from the parent form. But I'm confused with new UI elements. Is there a reason for this?
http://www.youtube.com/watch?v=y0UiX6kLvvs

Comments

  1. Not sure. Maybe a good nights sleep will make me remember (:

    ReplyDelete
  2. As far as I remember this doesn't matter. The inherited call does nothing because there is no inherited method. It still compiles. Still annoying though.

    ReplyDelete
  3. As said by others the inherited keyword inside event handlers (!) doesn't any harm when no base handler exists. Although it can be quite helpful when you decide to introduce such a handler inside the base form/frame later. Thus all those inherited classes will now automatically call this new base handler, which is ususally what you expect. Without this inherited call you would have to iterate over all those inherited classes and add it manually. This can be tedious in the case you reuse the base class in different projects.
    Note that an event handler is not declared virtual and the call to inherited has a slightly different implementation than that for a method declared as override.

    ReplyDelete

Post a Comment