本文整理汇总了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();
}
}
}
示例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());
}
});
示例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" });
});
}
});
示例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();
}
}
});
示例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'
};
});
示例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');
}
},
];
}
示例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: []
});
}
示例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);
}
})
示例9: getFocusedWebContents
function getFocusedWebContents(): WebContents {
const focusedWindow = BrowserWindow.getFocusedWindow()
return focusedWindow == null ? null : focusedWindow.webContents
}
示例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)
}
})