Duplicate name class and instance events

I have a custom control class myListbox based on the standard control and it has an Open event. I would like to add a second Open event to an instance of it in my app so the instance can use properties from the class and communicate with other controls after the main window and containers have opened.

I have seen something like this done in an example online with a text field and a lost focus event. The instance event kicks in after the Class event. Unfortunately I think the example was written a few years back and the interface has changed.

I have found out how to create an event definition using the Insert menu and this creates an event I can call Open but I can’t see how to connect this with the instance of my class. Also there is a red dot against the event name and when I open the code window it won’t allow me to type anything. Any suggestions?

Also, is there any way to determine the order in which Open events kick in when you have a window, containers and controls, some of them custom controls?

There are a lot of ways to approach the situation you describe. You will get other replies with some of those ways.
As for creating an event definition, after creating the definition as you ahve done, go to the instance of myListBox on your Window. Choose add an event and the event definition you created will be one of the choices. It is there that you put the code you want to run. You make this event definition fire by calling raiseEvent Open or whatever you have named it.
As for determining in what order Open event fire, the answer is a hearty NO. And we have been warned repeatedly not to rely on the order of events as it now exists as it might change in the future.

Unfortunately, this just takes me back to my first hurdle. I select the name of my instance, click on the Insert logo and select Event Hndler and I get a list of all the events I can add, but it doesn’t include Open, which has been used in the class. Same thing happens if I right click on the instance name. The only way I can find to include an instance Open event is to delete the Open class event.

In your superclass, implement the Open event.
Next, add to the superclass an event definition, you may call it Open, but I try to avoid using Xojo events just so I know it was an event I created. So for clarity, in this example I will call it Opened.
At the end of your superclass’ Open event add the line RaiseEvent Opened

Now, on your instance of that class you can add an Event Handler, you should see Opened (or Open if you so chose.)

Thanks very much to you both. I am learning so much with the help of you seasoned programmers. I’ve now created and used a binary file for the first time to hold app settings, used my new class to process the data on opening, and passed some information to popupmenus on my container in my class instance Opened event so they can populate themselves. Wow!