SOLFIND
Web Lens
Portal home

Menu | Electron

https://www.electronjs.org/ru/docs/latest/api/menu • 50 KB fetched
Open original page


Menu | Electron Перейти к основному содержанию Electron Документация API Блог Инструменты * Electron Forge * Electron Fiddle Сообщество * Управление * Примеры * Ресурсы Релизы Русский * English * Deutsch * Español * Français * 日本語 * Português * Русский * 中文 Поиск * Модули основного процесса * app * autoUpdater * BaseWindow * BrowserView * Deprecated * BrowserWindow * clipboard * contentTracing * crashReporter * desktopCapturer * dialog * globalShortcut * ImageView * inAppPurchase * ipcMain * Menu * MenuItem * MessageChannelMain * MessagePortMain * nativeImage * nativeTheme (Родная тема) * net * netLog * Notification (Оповещения) * powerMonitor * powerSaveBlocker * process * protocol * pushNotifications * safeStorage * screen * session * sharedTexture * ShareMenu * shell * systemPreferences * TouchBar * Tray * utilityProcess * webContents * WebContentsView * webFrameMain * View * Модули графического процесса * Utility Process Modules * Пользовательские DOM-элементы * Chromium и Node.js * Классы * Структуры API * * Модули основного процесса * Menu На этой странице Menu Класс: Menu ​ Create application menus and context menus. Process: Main The presentation of menus varies depending on the operating system: * Under Windows and Linux, menus are visually similar to Chromium. * Under macOS, these will be native menus. [!TIP] See also: A detailed guide about how to implement menus in your application . [!WARNING] Electron's built-in classes cannot be subclassed in user code. For more information, see the FAQ . new Menu() ​ Создает новое меню. Статические методы ​ Класс Menu имеет следующие статические методы: Menu.setApplicationMenu(menu) ​ * menu Menu | null Устанавливает меню в качестве меню приложения на macOS. On Windows and Linux, the menu will be set as each window's top menu. Также на Windows и Linux, Вы можете использовать & в названии подменю верхнего списка, чтобы указать, какая буква должна получить сгенерированный акселератор( Accelerator ). Для примера, использование &File для меню файла в результате сгенерирует акселератор( Accelerator ) Alt-F , который открывает соответствующее меню. The indicated character in the button label then gets an underline, and the & character is not displayed on the button label. In order to escape the & character in an item name, add a preceding & . For example, &&File would result in &File displayed on the button label. Passing null will suppress the default menu. On Windows and Linux, this has the additional effect of removing the menu bar from the window. [!NOTE] The default menu will be created automatically if the app does not set one. It contains standard items such as File , Edit , View , and Window . Menu.getApplicationMenu() ​ Возвращает Menu | null - меню приложения, если установлено, иначе null . [!NOTE] The returned Menu instance doesn't support dynamic addition or removal of menu items. Instance properties can still be dynamically modified. Menu.sendActionToFirstResponder(action) macOS ​ * action string Посылает action первому ответчику приложения. Это используется для эмуляции поведения меню macOS. Usually you would use the role property of a MenuItem . See the macOS Cocoa Event Handling Guide for more information on macOS' native actions. Menu.buildFromTemplate(template) ​ * template ( MenuItemConstructorOptions | MenuItem )[] Returns Menu Generally, the template is an array of options for constructing a MenuItem . The usage can be referenced above. Вы также можете прикрепить другие поля к элементу template и они станут свойствами элементов созданного меню. Методы экземпляра ​ Объект меню имеет следующие методы экземпляра: menu.popup([options]) ​ * options Object (опционально) * window BaseWindow (optional) - Default is the focused window. * frame WebFrameMain (optional) - Provide the relevant frame if you want certain OS-level features such as Writing Tools on macOS to function correctly. Typically, this should be params.frame from the context-menu event on a WebContents, or the focusedFrame property of a WebContents. * x number (optional) - Default is the current mouse cursor position. Must be declared if y is declared. * y number (optional) - Default is the current mouse cursor position. Must be declared if x is declared. * positioningItem number (optional) macOS - The index of the menu item to be positioned under the mouse cursor at the specified coordinates. Default is -1. * sourceType string (optional) Windows Linux - This should map to the menuSourceType provided by the context-menu event. It is not recommended to set this value manually, only provide values you receive from other APIs or leave it undefined . Can be none , mouse , keyboard , touch , touchMenu , longPress , longTap , touchHandle , stylus , adjustSelection , or adjustSelectionReset . * callback Функция (опционально) - вызывается, когда меню закрыто. Pops up this menu as a context menu in the BaseWindow . [!TIP] For more details, see the Context Menu guide. menu.closePopup([window]) ​ * window BaseWindow (optional) - Default is the focused window. Closes the context menu in the window . menu.append(menuItem) ​ * menuItem MenuItem Добавляет menuItem в меню. menu.getMenuItemById(id) ​ * id string Returns MenuItem | null - the item with the specified id menu.insert(pos, menuItem) ​ * port Integer * menuItem MenuItem Вставляет menuItem в меню на позицию pos . События экземпляра ​ Объекты созданные с помощью new Menu или возвращенные из Menu.buildFromTemplate вызывают следующие события: [!NOTE] Some events are only available on specific operating systems and are labeled as such. Событие: 'menu-will-show' ​ Возвращает: * event Event Вызывается при вызове menu.popup() . Событие: 'menu-will-close' ​ Возвращает: * event Event Вызывается, когда всплывающее окно закрывается вручную или с помощью menu.closePopup() . Свойства экземпляра ​ Объекты menu также имеют следующие свойства: menu.items ​ A MenuItem[] array containing the menu's items. Each Menu consists of multiple MenuItem instances and each MenuItem can nest a Menu into its submenu property. Редактировать эту страницу Назад ipcMain Далее MenuItem * Класс: Menu * new Menu() * Статические методы * setApplicationMenu * getApplicationMenu * sendActionToFirstResponder * buildFromTemplate * Методы экземпляра * popup * closePopup * append * getMenuItemById * insert * События экземпляра * Событие: 'menu-will-show' * Событие: 'menu-will-close' * Свойства экземпляра * items Документация * Начало работы * Справка по API Контрольные списки * Характеристика * Безопасность Инструменты * Electron Forge * Electron Fiddle Сообщество * Управление * Ресурсы * Discord * Bluesky * X * Mastodon * Stack Overflow Подробнее * GitHub * Open Collective * Панель управления инфраструктурой Авторское право OpenJS Foundation и участники проекта Electron. Все права защищены. OpenJS Foundation обладает зарегистрированными товарными знаками и использует их. Список товарных знаков OpenJS Foundation приведён в нашей Политике в отношении товарных знаков и в Списке товарных знаков . Товарные знаки™ и логотипы®, не указанные в списке товарных знаков OpenJS Foundation , являются товарными знаками™ или зарегистрированными® товарными знаками их владельцев. Их использование не подразумевает какой-либо принадлежности к ним или поддержки с их стороны. The OpenJS Foundation | Условия использования | Политика конфиденциальности | Устав | Кодекс поведения | Политика в отношении товарных знаков | Список товарных знаков | Политика использования файлов cookie Hosting and infrastructure graciously provided by

Links found on this page

  1. Перейти к основному содержанию [direct]
  2. Electron [direct]
  3. Документация [direct]
  4. API [direct]
  5. Блог [direct]
  6. Electron Forge [direct]
  7. Electron Fiddle [direct]
  8. Управление [direct]
  9. Примеры [direct]
  10. Ресурсы [direct]
  11. Релизы [direct]
  12. English [direct]
  13. Deutsch [direct]
  14. Español [direct]
  15. Français [direct]
  16. 日本語 [direct]
  17. Português [direct]
  18. 中文 [direct]
  19. autoUpdater [direct]
  20. BaseWindow [direct]
  21. BrowserView Deprecated [direct]
  22. BrowserWindow [direct]
  23. clipboard [direct]
  24. contentTracing [direct]
  25. crashReporter [direct]
  26. desktopCapturer [direct]
  27. dialog [direct]
  28. globalShortcut [direct]
  29. ImageView [direct]
  30. inAppPurchase [direct]
  31. ipcMain [direct]
  32. MenuItem [direct]
  33. MessageChannelMain [direct]
  34. MessagePortMain [direct]
  35. nativeImage [direct]
  36. nativeTheme (Родная тема) [direct]
  37. net [direct]
  38. netLog [direct]
  39. Notification (Оповещения) [direct]
  40. powerMonitor [direct]
  41. powerSaveBlocker [direct]
  42. process [direct]
  43. protocol [direct]
  44. pushNotifications [direct]
  45. safeStorage [direct]
  46. screen [direct]
  47. session [direct]
  48. sharedTexture [direct]
  49. ShareMenu [direct]
  50. shell [direct]
  51. systemPreferences [direct]
  52. TouchBar [direct]
  53. Tray [direct]
  54. utilityProcess [direct]
  55. webContents [direct]
  56. WebContentsView [direct]
  57. webFrameMain [direct]
  58. View [direct]
  59. Пользовательские DOM-элементы [direct]
  60. Chromium и Node.js [direct]
  61. Классы [direct]
  62. Структуры API [direct]
  63. Main [direct]
  64. A detailed guide about how to implement menus in your application [direct]
  65. the FAQ [direct]
  66. macOS Cocoa Event Handling Guide [direct]
  67. Context Menu [direct]
  68. Редактировать эту страницу [direct]
  69. Характеристика [direct]
  70. Безопасность [direct]
  71. Discord [direct]
  72. Bluesky [direct]
  73. X [direct]
  74. Mastodon [direct]
  75. Stack Overflow [direct]
  76. GitHub [direct]
  77. Open Collective [direct]
  78. Панель управления инфраструктурой [direct]
  79. OpenJS Foundation [direct]
  80. Политике в отношении товарных знаков [direct]