code_uimenuwindow.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. var utils = require("Scripts/utils");
  3. exports.init = function(mylayout,mylogger) {
  4. var button1 = mylayout.getWidget("uimenuwindowpush");
  5. button1.onClick = function () {
  6. mylogger.setText( "UIMenuWindow action : " + button1.id + " was pressed ");
  7. var mymenuwindow = new Atomic.UIMenuWindow( mylayout, "MenuWindowDemo");
  8. var mis = new Atomic.UIMenuItemSource();
  9. mis.addItem( new Atomic.UIMenuItem( "UISelectItem1", "item1" ) );
  10. mis.addItem( new Atomic.UIMenuItem( "UISelectItem2", "item2", "Ctrl+C" ) );
  11. mis.addItem( new Atomic.UIMenuItem( "UISelectItem2", "item3", "Ctrl+A", "DuckButton" ) );
  12. mis.addItem( new Atomic.UIMenuItem( "UISelectItem3", "item4", "Ctrl+O", "LogoAtomic" ) );
  13. var xx = button1.x + (button1.width/2);
  14. var yy = button1.y + (button1.height/2);
  15. mymenuwindow.show(mis, xx, yy);
  16. mymenuwindow.subscribeToEvent( "WidgetEvent", function (ev) {
  17. if ( ev.type == Atomic.UI_EVENT_TYPE_CLICK && ev.target == mymenuwindow )
  18. mylogger.setText( "UIMenuWindow action : " + mymenuwindow.id + " selected entry id = " + ev.refID + " event type = " + ev.type);
  19. if ( ev.type == Atomic.UI_EVENT_TYPE_SHORTCUT )
  20. mylogger.setText( "UIMenuWindow action : " + mymenuwindow.id + " Shortcut id = " + ev.refID + " event type = " + ev.type);
  21. });
  22. };
  23. var button2 = mylayout.getWidget("uimenuwindowcode");
  24. button2.onClick = function () {
  25. mylogger.setText( "UIMenuWindow action : " + button2.id + " was pressed ");
  26. utils.viewCode ( "Components/code_uimenuwindow.js", mylayout );
  27. };
  28. var button3 = mylayout.getWidget("uimenuwindowlayout");
  29. button3.onClick = function () {
  30. mylogger.setText( "UIMenuWindow action : " + button3.id + " was pressed ");
  31. utils.viewCode ( "Scenes/layout_uimenuwindow.ui.txt", mylayout );
  32. };
  33. };