I have a custom control and have added a event definition called “Click”. I added RaiseEvent Click to the MouseUp Event Handler so it fires. Everything is fine when I add the control to the window. The problem I have is that I already had a bunch of my custom controls added to the window (which I would like not to recreate) before I created the “Click” definition. I can’t seem to add the “Click” event handler to the controls that were already loaded, the “Click” event handler is not in the list of ones to add. I tried saving, exiting Xojo and opening up again but it still isn’t available for controls added before I added it. I must be missing something easy. I’m on Windows.
Are you certain the superclass of the older controls is the same as the class you added the Click event to?
Are these in a ControlSet? If so, you’ll only have one event handler for each event definition for all of the controls in the ControlSet.
and be sure you not have used this event inside of the control template.
you can handle a event in this sub classed control once or in the window where it is placed for each.
Thanks for the replies. The superclass for the buttons is the same. Here’s how the order of events went.
!) Opened a project with my custom button included, dragged a bunch of them onto the window and customized size, location, etc…
2) Saved and closed the project.
3) Reopened the project and edited the custom button by adding the new definition.
4) Added new buttons to the window, was able to add the newly created event for the button (works as expected)
*The old buttons same type, superclass that were dropped on the window before I added the new definition do not have the option to add the new event in the add events list.
I did nothing different than add the new definition to the control. I am using a ControlSet but I’ve verified that adding new buttons with a ControlSet gives me the event handler in the list.
Adding new buttons to the ControlSet will use the only one Event Handler you’ve selected. You can verify this by the “Index as Integer” parameter on the ControlSet’s event handler in the Event Handlers section.
If you put a
break in the Event Handler and click one of the old buttons, does it break?
Ok, it’s working now, I’m going to chalk it up to an oversight on my part. Maybe I was trying to add the handler to the individual controls in the ControlSet. Thanks Anthony.
Happy to help! Please mark whatever post best solved this issue as the solution in case others come along later with the same question.
Edit: You did it already! Good on you!