| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- import strings = require("./EditorStrings");
- import EditorEvents = require("../editor/EditorEvents");
- import EditorUI = require("./EditorUI");
- import MenuItemSources = require("./menus/MenuItemSources");
- class MainFrameMenu extends Atomic.ScriptObject {
- constructor() {
- super();
- MenuItemSources.createMenuItemSource("menu atomic editor", editorItems);
- MenuItemSources.createMenuItemSource("menu edit", editItems);
- MenuItemSources.createMenuItemSource("menu file", fileItems);
- }
- handlePopupMenu(target: Atomic.UIWidget, refid: string): boolean {
- if (target.id == "menu atomic editor popup") {
- if (refid == "quit") {
- this.sendEvent(EditorEvents.Quit);
- return true;
- }
- } else if (target.id == "menu edit popup") {
- if (refid == "edit play") {
- EditorUI.getShortcuts().invokePlay();
- return true;
- }
- if (refid == "edit format code") {
- EditorUI.getShortcuts().invokeFormatCode();
- return true;
- }
- return false;
- } else if (target.id == "menu file popup") {
- if (refid == "file new project") {
- var mo = EditorUI.getModelOps();
- mo.showNewProject();
- return true;
- }
- if (refid == "file save file") {
- EditorUI.getShortcuts().invokeFileSave();
- return true;
- }
- if (refid == "file close file") {
- EditorUI.getShortcuts().invokeFileClose();
- return true;
- }
- if (refid == "file save all") {
- this.sendEvent(EditorEvents.SaveAllResources);
- return true;
- }
- return false;
- }
- }
- }
- export = MainFrameMenu;
- // initialization
- var StringID = strings.StringID;
- var editorItems = {
- "About Atomic Editor": "about atomic editor",
- "-1": null,
- "Manage License": "manage license",
- "-2": null,
- "Check for Updates": "check update",
- "-3": null,
- "Quit": "quit"
- };
- var editItems = {
- "Undo": ["edit undo", StringID.ShortcutUndo],
- "Redo": ["edit redo", StringID.ShortcutRedo],
- "-1": null,
- "Cut": ["edit cut", StringID.ShortcutCut],
- "Copy": ["edit copy", StringID.ShortcutCopy],
- "Paste": ["edit paste", StringID.ShortcutPaste],
- "Select All": ["edit select all", StringID.ShortcutSelectAll],
- "-2": null,
- "Find": ["edit find", StringID.ShortcutFind],
- "Find Next": ["edit find next", StringID.ShortcutFindNext],
- "Find Prev": ["edit find prev", StringID.ShortcutFindPrev],
- "-3": null,
- "Format Code": ["edit format code", StringID.ShortcutBeautify],
- "-4": null,
- "Play": ["edit play", StringID.ShortcutPlay]
- };
- var fileItems = {
- "New Project": ["file new project"],
- "Open Project": ["file open project"],
- "Save Project": ["file save project"],
- "-1": null,
- "Close Project": ["file close project"],
- "-2": null,
- "Save File": ["file save file"],
- "Save All Files": ["file save all"],
- "Close File": ["file close file"]
- }
|