// get somehow the control instances of the subcontrols
const controlA = TcHmi.Controls.get(this.getId()+'.SubControlA')!;
const controlB = TcHmi.Controls.get(this.getId() + '.SubControlB')!;
const genericHandler: Parameters<typeof TcHmi.EventProvider.register>[1] = (event, data) => {
const ctrlName = event.name.split('.')[0]; // event.name is '<controlname>.onPressed'
if (ctrlName === 'ControlA') {
// do smart things with Control A
TcHmi.Log.infoEx(controlA.getId() + ' clicked' );
} else if (ctrlName === 'ControlB') {
// do smart things with Control B
TcHmi.Log.infoEx(controlB.getId() + ' clicked');
}
};
const destroyRegPressedA = TcHmi.EventProvider.register(controlA.getId() + '.onPressed', genericHandler);
const destroyRegPressedB =TcHmi.EventProvider.register(controlB.getId() + '.onPressed', genericHandler);
// both destroyRegPressed destroy callbacks should be called at the correct time to prevent memleak
// if register was done in __attach destroy it in __detach
// if register was done before __attach destroy it in __destroy