Another way of doing it is inside the TabControl you could do this.
PHP Code:
thiso.catchevent(this, "onSelect", "TabSelected");
or outside of the tab control:
PHP Code:
this.catchevent("TabControlName", "onSelect", "TabSelected");
All this basically does is call another function (with parameters) once the action of the specified GUI control has happened.