是否可以在Electron Framework中使用自定义窗口级别,以使窗口始终位于顶部,甚至其他应用程序也处于全屏状态?
对于 native MacOS应用程序,我发现了这一点:https://stackoverflow.com/a/27397096/5838242
他在哪里说:
window.level = Int(CGWindowLevelForKey(kCGMaximumWindowLevelKey))
在 Electron 上,我有一个浏览器窗口:
mainWindow = new BrowserWindow({width: 1400, height: 50, resizable: false, alwaysOnTop: true, y: 0, x: 0, minimizable: false, title: 'CD App', frame: false, titleBarStyle: 'hidden', type: 'desktop' });
我知道'type'参数是POINT,但是此参数只有两个选项:
On macOS, possible types are desktop, textured. The textured type adds metal gradient appearance (NSTexturedBackgroundWindowMask). The desktop type places the window at the desktop background window level (kCGDesktopWindowLevel - 1). Note that desktop window will not receive focus, keyboard or mouse events, but you can use globalShortcut to receive input sparingly.
那么,做这个事情有什么可能?
最佳答案
从Electron 1.4.2开始, setAlwaysOnTop()
API采用了可选的level
参数来调整窗口级别,您可以像这样使用它:
mainWindow = new BrowserWindow({ ... });
mainWindow.setAlwaysOnTop(true, 'screen');
有关可选参数的所有可能值,请参阅文档,在这种情况下,我不确定
screen
是否是您想要的参数,您需要进行实验。
关于macos - 设置browserWindow始终位于顶部,即使其他应用也处于全屏状态[Electron,MAC OS],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39835282/