如何在不使用-webkit-app-region的情况下在Electron中移动无框架窗口 [英] How do I move a frameless window in Electron without using -webkit-app-region

查看:156
本文介绍了如何在不使用-webkit-app-region的情况下在Electron中移动无框架窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图在false上移动无框窗口,但是现在我想仅通过拖动一个元素(标题栏)来移动整个窗口,我已经尝试过-webkit-app-region:拖动; 但它似乎不起作用,我也尝试过

I've been trying to move a frameless window on false but now I want to move the whole window just by dragging one element (the title bar), I've tried -webkit-app-region: drag; but it doesn't seem to work, I've also tried https://www.npmjs.com/package/electron-drag but it does't work either.

推荐答案

由于您的Windows没有框架,因此您可以使用属性 -webkit-app-region ,即使您的IDE指出该属性无效,该属性仍然有效.您只应该禁止文本选择,并且出于用户体验的考虑也将其拖到标题栏内的按钮上.

Since your windows are frameless you can use the property -webkit-app-region which is valid even though your IDE says it's not. You just should forbid the text selection and drag on buttons inside of your title bar too out of UX concerns.

.titlebar {
  -webkit-user-select: none;
  -webkit-app-region: drag;
}

.titlebar-button {
  -webkit-app-region: no-drag;
}

API文档也提到了这一点https://github.com/electron/electron/blob/master/docs/api/frameless-window.md#draggable-region

The API documentation mentions this too https://github.com/electron/electron/blob/master/docs/api/frameless-window.md#draggable-region

这篇关于如何在不使用-webkit-app-region的情况下在Electron中移动无框架窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆