How to add an open event to an inherited control

If one create a control as a class for the purpose of being inherited, then any event used cannot be in a inheriting control.
So. I have a LboxWSort without an open, and it is inherited. If I add the open event, I cannot also have that event in the inheriting control.

I would like to add somehow the line

me.hasheader = true

How do I do this?

Add an event definition to your class
Your class can implement the event and then pass it along by using RaiseEvent

As for properties you can also handle those
But you’d have to visit my blog and look for “Why shadowing should be avoided” and “follow up on why shadowing should be avoided”
In general you want to avoid shadowing BUT there is a way to do it for properties in a way that is “safer”

Oops. I forgot that I don’t always want a header.
Thanks. I’ll look for it.

I finally added my own event definition. Simple.
To a previous ListBox class I added an Event Definition
“HasHeader”.

I then added the event handler to the specific ListBoxes with the code

me.HasHeader = True

and it works.

In your blog you suggested adding a computed property. How would that work?

In your subclass add the computed property
In the get portion you would return

       Listbox(me).HasHeader

And in the setter you would set

      Listbox(me).HasHeader = value

The cast to the super type is important when you shadow properties

And this call to the property would be in the event AddHeader?

Not sure why you want to make addheader an event ?
I’m obviously missing something here

I’m trying to learn your technique. This is the uhmm normal way.

https://forum.xojo.com/7642-making-a-custom-event-handler

My question is more of where do I put the call to the computed property

Making a custom event handler is as simple as defining a new Event (adding an event definition) and then, in whatever code your subclass has raising that event at appropriate times (you have to determine what those are)

I really dont understand what calling a computed property has to do with defining an event ???

your fist post posed 2 questions (not one)

  1. how to aI add the open event in way that instance of my subclass can implement it when they are added to a layout (which is what I have addressed)

  2. how can I add my own property to my subclass so I can write

This is my blog post on shadowing

they are not the same question nor do they have the same answer

Nom, in your “old” blog there is an entry “Why shadowing should be avoided”. I did not see one for “follow up on why shadowing should be avoided”.

At the end of the entry for “Why shadowing should be avoided” there is an link:

And here’s a sample that shows the bad version and how to make it work as expected. Click on “here’s a sample” takes you to a Yahoo financial page.

irony?

here it downloads the sample from http://great-white-software.com/gws-rb-samples/WhyShadowingIsBadAndHowToDoItProperly.xojo_binary_project