code_uitabcontainer.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. var utils = require("Scripts/utils");
  3. exports.init = function(mylayout,mylogger) {
  4. var tb = mylayout.getWidget("UITabContainerDemo");
  5. tb.setCurrentPage(0); // fix or it looks like crap
  6. tb.subscribeToEvent( "WidgetEvent", function (ev) {
  7. if ( ev.type == Atomic.UI_EVENT_TYPE_TAB_CHANGED && tb == ev.target ) {
  8. mylogger.setText( "UITabContainer action : " + tb.id + " UI_EVENT_TYPE_TAB_CHANGED to " + tb.getCurrentPage() + " id: " + tb.getCurrentPageWidget().id);
  9. }
  10. });
  11. var button1 = mylayout.getWidget("uitabcontainerremove");
  12. button1.onClick = function () {
  13. mylogger.setText( "UITabContainer action : " + button1.id + " was pressed ");
  14. var current = tb.getCurrentPage();
  15. tb.deletePage(current);
  16. };
  17. var button2 = mylayout.getWidget("uitabcontaineradd");
  18. button2.onClick = function () {
  19. mylogger.setText( "UITabContainer action : " + button2.id + " was pressed ");
  20. tb.addTabPageFile("New File", "Scenes/sheet.ui.txt" );
  21. };
  22. var button3 = mylayout.getWidget("uitabcontainermake");
  23. button3.onClick = function () {
  24. mylogger.setText( "UITabContainer action : " + button3.id + " was pressed ");
  25. var lo = new Atomic.UILayout();
  26. lo.setLayoutConfig ( "YACAC" ); // YACAC!
  27. lo.addChild ( new Atomic.UIButton() );
  28. lo.addChild ( new Atomic.UIButton() );
  29. lo.addChild ( new Atomic.UIButton() );
  30. lo.addChild ( new Atomic.UIButton() );
  31. lo.addChild ( new Atomic.UIButton() );
  32. tb.addTabPageWidget("New Code", lo );
  33. };
  34. var button4 = mylayout.getWidget("uitabcontainercode");
  35. button4.onClick = function () {
  36. mylogger.setText( "UITabContainer action : " + button4.id + " was pressed ");
  37. utils.viewCode ( "Components/code_uitabcontainer.js", mylayout );
  38. };
  39. var button5 = mylayout.getWidget("uitabcontainerlayout");
  40. button5.onClick = function () {
  41. mylogger.setText( "UITabContainer action : " + button5.id + " was pressed ");
  42. utils.viewCode ( "Scenes/layout_uitabcontainer.ui.txt", mylayout );
  43. };
  44. };