Just discovered that this article about architecture of behaviors was written 10 years ago and still actual.
It is just that instead of artificial Behavior class you should use Element
now:
class ColorChooser: Element { this var _value = null; function attached() { ... } function detached() { ... } event "click|popup td" (evt) { // handling click on td in popup } }