admin管理员组文章数量:1402851
I have created electron app which on button click shows another window which is 100% height and width and has border around its area. It's also transparent so you can see what is behind this window.
Now I'm wondering if I'm able to make things below clickable or I need to create some kind of hack like this new transparent window make it really small and somehow expand border off this window.
Code responsible for creating new transparent window is:
const electron = require('electron');
const { app, BrowserWindow, Menu } = electron;
let mainWindow;
let addWindow;
let createTransparentWindow;
app.on('ready', () => {
mainWindow = new BrowserWindow({});
mainWindow.loadURL(`file://${__dirname}/index.html`);
const mainMenu = Menu.buildFromTemplate(menuTemplate);
Menu.setApplicationMenu(mainMenu);
const mainScreen = electron.screen.getPrimaryDisplay();
createTransparentWindow = () => {
addWindow = new BrowserWindow({
width: mainScreen.size.width,
height: mainScreen.size.height,
transparent: true,
frame: false,
alwaysOnTop: true,
});
addWindow.loadURL(`file://${__dirname}/transparentWindow.html`)
};
});
const menuTemplate = [
{},
{
label: 'Record',
submenu: [
{
label: 'TransparentWindow',
click() {
createTransparentWindow();
}
}
]
}
];
If I'm able to make apps which are below this window clickable please tell me how if not what kinda trick I need to introduce here?
I have created electron app which on button click shows another window which is 100% height and width and has border around its area. It's also transparent so you can see what is behind this window.
Now I'm wondering if I'm able to make things below clickable or I need to create some kind of hack like this new transparent window make it really small and somehow expand border off this window.
Code responsible for creating new transparent window is:
const electron = require('electron');
const { app, BrowserWindow, Menu } = electron;
let mainWindow;
let addWindow;
let createTransparentWindow;
app.on('ready', () => {
mainWindow = new BrowserWindow({});
mainWindow.loadURL(`file://${__dirname}/index.html`);
const mainMenu = Menu.buildFromTemplate(menuTemplate);
Menu.setApplicationMenu(mainMenu);
const mainScreen = electron.screen.getPrimaryDisplay();
createTransparentWindow = () => {
addWindow = new BrowserWindow({
width: mainScreen.size.width,
height: mainScreen.size.height,
transparent: true,
frame: false,
alwaysOnTop: true,
});
addWindow.loadURL(`file://${__dirname}/transparentWindow.html`)
};
});
const menuTemplate = [
{},
{
label: 'Record',
submenu: [
{
label: 'TransparentWindow',
click() {
createTransparentWindow();
}
}
]
}
];
If I'm able to make apps which are below this window clickable please tell me how if not what kinda trick I need to introduce here?
Share Improve this question asked May 2, 2018 at 20:19 BT101BT101 3,84611 gold badges48 silver badges101 bronze badges 1- Doesn't seem to work on linux. – jayarjo Commented Sep 27, 2020 at 7:24
1 Answer
Reset to default 7I found answer to my question here. So what you need to browserWindow is:
addWindow.setIgnoreMouseEvents(true);
addWindow.setFocusable(false);
and then you can click through.
本文标签: javascriptCreate electron transparent window ontop but clickable below programsStack Overflow
版权声明:本文标题:javascript - Create electron transparent window ontop but clickable below programs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744367542a2602854.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论