You could use the AfterCreate event handler. Double click the entity and select the Event Handler tab. There you can set your event handlers.
[EDIT] I may have misread the question. Are you working on a custom widget?
Could you post your widget code, because I am wondering if you subscribed on updates?
Thanks Ronald for the answer, I probably mistyped the question, basically I am trying to track different clicks on the application, I what to know when users click on buttons, menu bars and navigation trees, and base on that execute some code,
the problem that I am facing is that I have placed an onclick event handler in a custom widget that is placed in layout, and when the first page is displayed, the event handlers get attached, but when for example I request another page by clicking a button or a menu option,and this page get loaded with buttons, menu bars or navigation trees it seems that the on click handler does not get attached to those items, because I can see from debugging it that the code inside the on click event doesn't trigger.