MainFrameMenu.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import strings = require("./EditorStrings");
  2. import EditorEvents = require("../editor/EditorEvents");
  3. import EditorUI = require("./EditorUI");
  4. import MenuItemSources = require("./menus/MenuItemSources");
  5. class MainFrameMenu extends Atomic.ScriptObject {
  6. constructor() {
  7. super();
  8. MenuItemSources.createMenuItemSource("menu atomic editor", editorItems);
  9. MenuItemSources.createMenuItemSource("menu edit", editItems);
  10. MenuItemSources.createMenuItemSource("menu file", fileItems);
  11. }
  12. handlePopupMenu(target: Atomic.UIWidget, refid: string): boolean {
  13. if (target.id == "menu atomic editor popup") {
  14. if (refid == "quit") {
  15. this.sendEvent(EditorEvents.Quit);
  16. return true;
  17. }
  18. } else if (target.id == "menu edit popup") {
  19. if (refid == "edit play") {
  20. EditorUI.getShortcuts().invokePlay();
  21. return true;
  22. }
  23. if (refid == "edit format code") {
  24. EditorUI.getShortcuts().invokeFormatCode();
  25. return true;
  26. }
  27. return false;
  28. } else if (target.id == "menu file popup") {
  29. if (refid == "file new project") {
  30. var mo = EditorUI.getModelOps();
  31. mo.showNewProject();
  32. return true;
  33. }
  34. if (refid == "file save file") {
  35. EditorUI.getShortcuts().invokeFileSave();
  36. return true;
  37. }
  38. if (refid == "file close file") {
  39. EditorUI.getShortcuts().invokeFileClose();
  40. return true;
  41. }
  42. if (refid == "file save all") {
  43. this.sendEvent(EditorEvents.SaveAllResources);
  44. return true;
  45. }
  46. return false;
  47. }
  48. }
  49. }
  50. export = MainFrameMenu;
  51. // initialization
  52. var StringID = strings.StringID;
  53. var editorItems = {
  54. "About Atomic Editor": "about atomic editor",
  55. "-1": null,
  56. "Manage License": "manage license",
  57. "-2": null,
  58. "Check for Updates": "check update",
  59. "-3": null,
  60. "Quit": "quit"
  61. };
  62. var editItems = {
  63. "Undo": ["edit undo", StringID.ShortcutUndo],
  64. "Redo": ["edit redo", StringID.ShortcutRedo],
  65. "-1": null,
  66. "Cut": ["edit cut", StringID.ShortcutCut],
  67. "Copy": ["edit copy", StringID.ShortcutCopy],
  68. "Paste": ["edit paste", StringID.ShortcutPaste],
  69. "Select All": ["edit select all", StringID.ShortcutSelectAll],
  70. "-2": null,
  71. "Find": ["edit find", StringID.ShortcutFind],
  72. "Find Next": ["edit find next", StringID.ShortcutFindNext],
  73. "Find Prev": ["edit find prev", StringID.ShortcutFindPrev],
  74. "-3": null,
  75. "Format Code": ["edit format code", StringID.ShortcutBeautify],
  76. "-4": null,
  77. "Play": ["edit play", StringID.ShortcutPlay]
  78. };
  79. var fileItems = {
  80. "New Project": ["file new project"],
  81. "Open Project": ["file open project"],
  82. "Save Project": ["file save project"],
  83. "-1": null,
  84. "Close Project": ["file close project"],
  85. "-2": null,
  86. "Save File": ["file save file"],
  87. "Save All Files": ["file save all"],
  88. "Close File": ["file close file"]
  89. }