Event Handlers

I am trying to get multiple controls of the same type to respond to the same event handlers. Does anyone have any thoughts as to how to best achieve this?

Yup, use Control Sets.

See Xojo User Guide Book 2 http://documentation.xojo.com

What do you mean exactly? You want to implement the same code in the event handlers of multiple controls? Or is it something else?

Sounds like, from your brief description, that Gavin’s suggestion of control sets will do it fr you. If you want to respond to your own event definitions, you may want to subclass the control, then create multiple instances of the subclass

Keep in mind that control sets only work for controls of the same type. If they’re different, you could use AddHandler to direct the events to a single method.


Wow, thank you for the quick response. I’m new to this forum and I did not anticipate such an active membership. I did take a look section 2.16 in Guide Book 2, but I need a bit of clarification. Section 2.16 in Guide Book 2 states “To create a new Control Set for the selected control, choose New Control Set from the popup menu”. How do I get this popup menu? When I right click on the control, I don’t see that option… and I don’t see it in the Inspector window. I appreciate your insights.

Select your control, then in the inspector click the gear icon - there you’ll see the control set data. This was moved in a recent release from the main Inspector panel.

Thank you for the clarification Wayne.

A neat shortcut is to duplicate your control, then name it exactly the same as the control you just duplicated.

Let’s say you have a PushButton named “btnDoIt”. Duplicate that and the new name becomes something like “btnDoIt1”. Remove the 1, and as soon as you try to commit, the IDE asks if you’d like to create a control set.