ScriptWidget.ts 944 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. class ScriptWidget extends Atomic.UIWidget {
  8. constructor() {
  9. super();
  10. // JS way of binding method
  11. // this.subscribeToEvent(this, "WidgetEvent", this.handleWidgetEvent.bind(this));
  12. // TypeScript-ey
  13. this.subscribeToEvent(this, "WidgetEvent", (data) => this.handleWidgetEvent(data));
  14. }
  15. onEventClick(target: Atomic.UIWidget, refid: string): boolean {
  16. return false;
  17. }
  18. handleWidgetEvent(ev: Atomic.UIWidgetEvent): void {
  19. if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
  20. this.onEventClick(ev.target, ev.refid);
  21. return;
  22. }
  23. }
  24. }
  25. export = ScriptWidget;