MainFrameMenu.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. new ToolCore.PlayCmd().run();
  21. return true;
  22. }
  23. return false;
  24. } else if (target.id == "menu file popup") {
  25. if (refid == "file new project") {
  26. var mo = EditorUI.getModelOps();
  27. mo.showNewProject();
  28. return true;
  29. }
  30. if (refid == "file save file") {
  31. this.sendEvent(EditorEvents.SaveResource);
  32. return true;
  33. }
  34. return false;
  35. }
  36. }
  37. }
  38. export = MainFrameMenu;
  39. // initialization
  40. var StringID = strings.StringID;
  41. var editorItems = {
  42. "About Atomic Editor": "about atomic editor",
  43. "-1": null,
  44. "Manage License": "manage license",
  45. "-2": null,
  46. "Check for Updates": "check update",
  47. "-3": null,
  48. "Quit": "quit"
  49. };
  50. var editItems = {
  51. "Undo": ["edit undo", StringID.ShortcutUndo],
  52. "Redo": ["edit redo", StringID.ShortcutRedo],
  53. "-1": null,
  54. "Cut": ["edit cut", StringID.ShortcutCut],
  55. "Copy": ["edit copy", StringID.ShortcutCopy],
  56. "Paste": ["edit paste", StringID.ShortcutPaste],
  57. "Select All": ["edit select all", StringID.ShortcutSelectAll],
  58. "-2": null,
  59. "Find": ["edit find", StringID.ShortcutFind],
  60. "Find Next": ["edit find next", StringID.ShortcutFindNext],
  61. "Find Prev": ["edit find prev", StringID.ShortcutFindPrev],
  62. "-3": null,
  63. "Format Code": ["edit format code", StringID.ShortcutBeautify],
  64. "-4": null,
  65. "Play": ["edit play", StringID.ShortcutPlay]
  66. };
  67. var fileItems = {
  68. "New Project": ["file new project"],
  69. "Open Project": ["file open project"],
  70. "Save Project": ["file save project"],
  71. "-1": null,
  72. "Close Project": ["file close project"],
  73. "-2": null,
  74. "Save File": ["file save file"],
  75. "Close File": ["file close file"]
  76. }