當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript BrowserWindow.fromWebContents方法代碼示例

本文整理匯總了TypeScript中electron.BrowserWindow.fromWebContents方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript BrowserWindow.fromWebContents方法的具體用法?TypeScript BrowserWindow.fromWebContents怎麽用?TypeScript BrowserWindow.fromWebContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在electron.BrowserWindow的用法示例。


在下文中一共展示了BrowserWindow.fromWebContents方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: findMenuItemByID

 (event: Electron.IpcMessageEvent, { id }: { id: string }) => {
   const menuItem = findMenuItemByID(menu, id)
   if (menuItem) {
     const window = BrowserWindow.fromWebContents(event.sender)
     const fakeEvent = { preventDefault: () => {}, sender: event.sender }
     menuItem.click(fakeEvent, window, event.sender)
   }
 }
開發者ID:tamdao,項目名稱:desktop,代碼行數:8,代碼來源:main.ts

示例2: buildContextMenu

    (event: Electron.IpcMessageEvent, items: ReadonlyArray<IMenuItem>) => {
      const menu = buildContextMenu(items, ix =>
        event.sender.send('contextual-menu-action', ix)
      )

      const window = BrowserWindow.fromWebContents(event.sender)
      menu.popup({ window })
    }
開發者ID:ghmoore,項目名稱:desktop,代碼行數:8,代碼來源:main.ts

示例3: createMenu

	ipcMain.on(CONTEXT_MENU_CHANNEL, (event: Event, contextMenuId: number, items: ISerializableContextMenuItem[], onClickChannel: string, options?: IPopupOptions) => {
		const menu = createMenu(event, onClickChannel, items);

		menu.popup({
			window: BrowserWindow.fromWebContents(event.sender),
			x: options ? options.x : void 0,
			y: options ? options.y : void 0,
			positioningItem: options ? options.positioningItem : void 0,
			callback: () => {
				event.sender.send(CONTEXT_MENU_CLOSE_CHANNEL, contextMenuId);
			}
		});
	});
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:13,代碼來源:contextmenu.ts

示例4: Menu

    (event: Electron.IpcMessageEvent, items: ReadonlyArray<any>) => {
      const menu = new Menu()
      const menuItems = items.map((item, i) => {
        return new MenuItem({
          label: item.label,
          click: () => event.sender.send('contextual-menu-action', i),
          type: item.type,
          enabled: item.enabled,
        })
      })

      for (const item of menuItems) {
        menu.append(item)
      }

      const window = BrowserWindow.fromWebContents(event.sender)
      menu.popup(window, { async: true })
    }
開發者ID:tamdao,項目名稱:desktop,代碼行數:18,代碼來源:main.ts

示例5: createMenu

	ipcMain.on(CONTEXT_MENU_CHANNEL, (event: Event, contextMenuId: number, items: ISerializableContextMenuItem[], onClickChannel: string, options?: IPopupOptions) => {
		const menu = createMenu(event, onClickChannel, items);

		menu.popup({
			window: BrowserWindow.fromWebContents(event.sender),
			x: options ? options.x : undefined,
			y: options ? options.y : undefined,
			positioningItem: options ? options.positioningItem : undefined,
			callback: () => {
				// Workaround for https://github.com/Microsoft/vscode/issues/72447
				// It turns out that the menu gets GC'ed if not referenced anymore
				// As such we drag it into this scope so that it is not being GC'ed
				if (menu) {
					event.sender.send(CONTEXT_MENU_CLOSE_CHANNEL, contextMenuId);
				}
			}
		});
	});
開發者ID:PKRoma,項目名稱:vscode,代碼行數:18,代碼來源:contextmenu.ts

示例6: Menu

    (event: Electron.IpcMessageEvent, items: ReadonlyArray<any>) => {
      const menu = new Menu()
      const menuItems = items.map((item, i) => {
        return new MenuItem({
          label: item.label,
          click: () => event.sender.send('contextual-menu-action', i),
          type: item.type,
          enabled: item.enabled,
        })
      })

      for (const item of menuItems) {
        menu.append(item)
      }

      const window = BrowserWindow.fromWebContents(event.sender)
      // TODO: read https://github.com/desktop/desktop/issues/1003
      // to clean up this sin against T Y P E S
      const anyMenu: any = menu
      anyMenu.popup(window, { async: true })
    }
開發者ID:Aj-ajaam,項目名稱:desktop,代碼行數:21,代碼來源:main.ts


注:本文中的electron.BrowserWindow.fromWebContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。