Close Events for Subclassed Controls

Let’s say I have a subclassed control that has a close method

MyPopupMenu.close

I also have a child control

MyPopupMenuChild.close // Not allowed. Compiler says .close doesn't exist.

How can I have a close event for both parent and child so they can clean up their stuff when closing?

Add new Event Definition and then call it from the base class. Here is the relevant section of the User Guide:

OO Events

For cleaning up stuff you migh also want to consider a Destructor. A Destructor is called before an object gets destroyed (e.g for a popupmenu when the window is closed) and doesn’t require you to call another method like “close”.

I tend to avoid destructors because my objects often reference other objects. And those might reference me back. In that case, unless I clear my reference to them with a Close event or own created Kill event, the destructor might never get called. So I generally go around deliberately killing off my objects (and still sleep well at night).