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


TypeScript BrowserWindow.getFocusedWindow方法代碼示例

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


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

示例1: toggleMaximizeWindow

async function toggleMaximizeWindow() {
  const window = BrowserWindow.getFocusedWindow();
  if (window) {
    if (window.isMaximized()) {
      window.unmaximize();
    } else {
      window.maximize();
    }
  }
}
開發者ID:HorrerGames,項目名稱:itch,代碼行數:10,代碼來源:main-window.ts

示例2: async

 watcher.on(actions.openDevTools, async (store, action) => {
   const { wind, tab } = action.payload;
   if (tab) {
     const { tab } = store.getState().winds[wind].navigation;
     withWebContents(store, wind, tab, wc => {
       wc.openDevTools({ mode: "detach" });
     });
   } else {
     openAppDevTools(BrowserWindow.getFocusedWindow());
   }
 });
開發者ID:itchio,項目名稱:itch,代碼行數:11,代碼來源:web-contents.ts

示例3: async

 watcher.on(actions.openDevTools, async (store, action) => {
   const { window, forApp } = action.payload;
   if (forApp) {
     await openAppDevTools(BrowserWindow.getFocusedWindow());
   } else {
     const { tab } = store.getState().windows[window].navigation;
     withWebContents(store, window, tab, wc => {
       wc.openDevTools({ mode: "bottom" });
     });
   }
 });
開發者ID:HorrerGames,項目名稱:itch,代碼行數:11,代碼來源:web-contents.ts

示例4: async

  watcher.on(actions.quitWhenMain, async (store, action) => {
    const mainId = getNativeState(store.getState(), "root").id;
    const focused = BrowserWindow.getFocusedWindow();

    if (focused) {
      if (focused.id === mainId) {
        store.dispatch(actions.quit({}));
      } else {
        focused.close();
      }
    }
  });
開發者ID:HorrerGames,項目名稱:itch,代碼行數:12,代碼來源:main-window.ts

示例5: async

        this.router.get('/devTools', async (ctx, next) => {
            const win = BrowserWindow.getFocusedWindow();
            if (win) {
                win.webContents.openDevTools({
                    mode: 'detach'
                });

                setTimeout(() => win.focus(), 2000);
            }

            ctx.body = {
                message: 'success'
            };
        });
開發者ID:BabylonJS,項目名稱:Editor,代碼行數:14,代碼來源:tools.ts

示例6: getHelpItems

/**
 * Returns additional items for the help menu
 *
 * @returns {Array<Electron.MenuItemConstructorOptions>}
 */
function getHelpItems(): Array<MenuItemConstructorOptions> {
  return [
    {
      type: 'separator'
    },
    {
      label: 'Show Welcome Tour',
      click() {
        ipcMainManager.send(IpcEvents.SHOW_WELCOME_TOUR);
      }
    },
    {
      type: 'separator'
    },
    {
      label: 'Toggle Developer Tools',
      accelerator: 'CmdOrCtrl+Option+i',
      click() {
        const browserWindow = BrowserWindow.getFocusedWindow();

        if (browserWindow && !browserWindow.isDestroyed()) {
          browserWindow.webContents.openDevTools({ mode: 'bottom' });
        }
      }
    },
    {
      type: 'separator'
    },
    {
      label: 'Open Fiddle Repository...',
      click() {
        shell.openExternal('https://github.com/electron/fiddle');
      }
    },
    {
      label: 'Open Electron Repository...',
      click() {
        shell.openExternal('https://github.com/electron/electron');
      }
    },
    {
      label: 'Open Electron Issue Tracker...',
      click() {
        shell.openExternal('https://github.com/electron/electron/issues');
      }
    },
  ];
}
開發者ID:bpasero,項目名稱:fiddle,代碼行數:53,代碼來源:menu.ts

示例7: showAboutBox

function showAboutBox() {
    var packageJSON = require("../../package.json");
    var version = packageJSON.version;

    var stats = fs.statSync(process.execPath);
    var mtime = new Date(stats.mtime);
    var buildDate = mtime.toString();

    dialog.showMessageBox(BrowserWindow.getFocusedWindow()!, {
        type: "info",
        title: "EEZ Studio",
        message: "EEZ Studio",
        detail: `Version: ${version}\nBuild date: ${buildDate}`,
        buttons: []
    });
}
開發者ID:eez-open,項目名稱:studio,代碼行數:16,代碼來源:about-box.ts

示例8: download

ipcMain.on('download-file-message', (event, args) => {
  console.log(args)  // prints "ping"
  event.sender.send('download-file-reply', 'pong');

  var folderPaths = dialog.showOpenDialog({ properties: ['openDirectory'] });
  console.log(folderPaths);

  if (folderPaths.length > 0) {
    download(BrowserWindow.getFocusedWindow(), args.url, {
      directory: folderPaths[0],
      filename: args.fileName
    })
      .then(dl => console.log(dl.getSavePath()))
      .catch(console.error);
  }
})
開發者ID:mangabot,項目名稱:mangabot,代碼行數:16,代碼來源:main.ts

示例9: getFocusedWebContents

function getFocusedWebContents(): WebContents {
  const focusedWindow = BrowserWindow.getFocusedWindow()
  return focusedWindow == null ? null : focusedWindow.webContents
}
開發者ID:agozie,項目名稱:onshape-desktop-shell,代碼行數:4,代碼來源:AppMenuManager.ts

示例10: it

 it('should return a positive number for critical type', () => {
   const appHasFocus = !!BrowserWindow.getFocusedWindow()
   if (!appHasFocus) {
     expect(app.dock.bounce('critical')).to.be.at.least(0)
   }
 })
開發者ID:malept,項目名稱:electron,代碼行數:6,代碼來源:api-app-spec.ts


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