MainFrameMenu.ts 2.8 KB

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