99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

Electron Tray 模塊

2019-08-14 19:21 更新

用一個 Tray 來表示一個圖標,這個圖標處于正在運行的系統(tǒng)的通知區(qū) ,通常被添加到一個 context menu 上.

const electron = require('electron');
const app = electron.app;
const Menu = electron.Menu;
const Tray = electron.Tray;

var appIcon = null;
app.on('ready', function(){
  appIcon = new Tray('/path/to/my/icon');
  var contextMenu = Menu.buildFromTemplate([
    { label: 'Item1', type: 'radio' },
    { label: 'Item2', type: 'radio' },
    { label: 'Item3', type: 'radio', checked: true },
    { label: 'Item4', type: 'radio' }
  ]);
  appIcon.setToolTip('This is my application.');
  appIcon.setContextMenu(contextMenu);
});

平臺限制:

  • 在 Linux, 如果支持應(yīng)用指示器則使用它,否則使用 GtkStatusIcon 代替.
  • 在 Linux ,配置了只有有了應(yīng)用指示器的支持, 你必須安裝 libappindicator1 來讓 tray icon 執(zhí)行.
  • 應(yīng)用指示器只有在它擁有 context menu 時才會顯示.
  • 當在linux 上使用了應(yīng)用指示器,將忽略點擊事件.
  • 在 Linux,為了讓單獨的 MenuItem 起效,需要再次調(diào)用 setContextMenu .例如:
contextMenu.items[2].checked = false;
appIcon.setContextMenu(contextMenu);

如果想在所有平臺保持完全相同的行為,不應(yīng)該依賴點擊事件,而是一直將一個 context menu 添加到 tray icon.

Class: Tray

Tray 是一個 事件發(fā)出者.

new Tray(image)

創(chuàng)建一個與 image 相關(guān)的 icon.

事件

Tray 模塊可發(fā)出下列事件:

注意: 一些事件只能在特定的os中運行,已經(jīng)標明.

Event: 'click'

  • event Event
    • altKey Boolean
    • shiftKey Boolean
    • ctrlKey Boolean
    • metaKey Boolean
  • bounds Object - tray icon 的 bounds.
    • x Integer
    • y Integer
    • width Integer
    • height Integer

當tray icon被點擊的時候發(fā)出事件.

注意: bounds 只在 OS X 和 Windows 上起效.

Event: 'right-click' OS X Windows

  • event Event
    • altKey Boolean
    • shiftKey Boolean
    • ctrlKey Boolean
    • metaKey Boolean
  • bounds Object - tray icon 的 bounds.
    • x Integer
    • y Integer
    • width Integer
    • height Integer

當tray icon被鼠標右鍵點擊的時候發(fā)出事件.

Event: 'double-click' OS X Windows

  • event Event
    • altKey Boolean
    • shiftKey Boolean
    • ctrlKey Boolean
    • metaKey Boolean
  • bounds Object - tray icon 的 bounds.
    • x Integer
    • y Integer
    • width Integer
    • height Integer

當tray icon被雙擊的時候發(fā)出事件.

Event: 'balloon-show' Windows

當tray 氣泡顯示的時候發(fā)出事件.

Event: 'balloon-click' Windows

當tray 氣泡被點擊的時候發(fā)出事件.

Event: 'balloon-closed' Windows

當tray 氣泡關(guān)閉的時候發(fā)出事件,因為超時或人為關(guān)閉.

Event: 'drop' OS X

當tray icon上的任何可拖動項被刪除的時候發(fā)出事件.

Event: 'drop-files' OS X

  • event
  • files Array - 已刪除文件的路徑.

當tray icon上的可拖動文件被刪除的時候發(fā)出事件.

Event: 'drag-enter' OS X

當一個拖動操作進入tray icon的時候發(fā)出事件.

Event: 'drag-leave' OS X

當一個拖動操作離開tray icon的時候發(fā)出事件. Emitted when a drag operation exits the tray icon.

Event: 'drag-end' OS X

當一個拖動操作在tray icon上或其它地方停止拖動的時候發(fā)出事件.

方法

Tray 模塊有以下方法:

Note: 一些方法只能在特定的os中運行,已經(jīng)標明.

Tray.destroy()

立刻刪除 tray icon.

Tray.setImage(image)

 image 與 tray icon 關(guān)聯(lián)起來.

Tray.setPressedImage(image) OS X

當在 OS X 上按壓 tray icon 的時候, 讓 image 與 tray icon 關(guān)聯(lián)起來.

Tray.setToolTip(toolTip)

  • toolTip String

為 tray icon 設(shè)置 hover text.

Tray.setTitle(title) OS X

  • title String

在狀態(tài)欄沿著 tray icon 設(shè)置標題.

Tray.setHighlightMode(highlight) OS X

  • highlight Boolean

當 tray icon 被點擊的時候,是否設(shè)置它的背景色變?yōu)楦吡?blue).默認為 true.

Tray.displayBalloon(options) Windows

  • options Object

展示一個 tray balloon.

Tray.popUpContextMenu([menu, position]) OS X Windows

  • menu Menu (optional)
  • position Object (可選) - 上托位置.
    • x Integer
    • y Integer

從 tray icon 上托出 context menu . 當劃過 menu 的時候, menu 顯示,代替 tray 的 context menu .

position 只在 windows 上可用,默認為 (0, 0) .

Tray.setContextMenu(menu)

  • menu Menu

為這個 icon 設(shè)置 context menu .

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號