ScriptWidget.ts 666 B

123456789101112131415161718192021222324252627282930313233343536
  1. class ScriptWidget extends Atomic.UIWidget {
  2. constructor() {
  3. super();
  4. // JS way of binding method
  5. // this.subscribeToEvent(this, "WidgetEvent", this.handleWidgetEvent.bind(this));
  6. // TypeScript-ey
  7. this.subscribeToEvent(this, "WidgetEvent", (data) => this.handleWidgetEvent(data));
  8. }
  9. onEventClick(target: Atomic.UIWidget, refid: string): boolean {
  10. return false;
  11. }
  12. handleWidgetEvent(ev: Atomic.UIWidgetEvent): void {
  13. if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
  14. this.onEventClick(ev.target, ev.refid);
  15. return;
  16. }
  17. }
  18. }
  19. export = ScriptWidget;