当前位置: 首页>>代码示例>>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;未经允许,请勿转载。