code_uimenuwindow.js 2.5 KB

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