-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
新增:输入框有内容时ESC也会关闭窗口 #233
新增:输入框有内容时ESC也会关闭窗口 #233
Conversation
README.md文档的功能列表没添加,如果能够合并的话,可以加一下这个功能到列表 |
增加ESC隐藏窗口的异常捕获
经测试,功能无效, |
* @return {void} 此函数不返回任何内容。 | ||
*/ | ||
export function escapeWindowWithInput(window) { | ||
window.webContents.on("keyup", async (event, input) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webContents
中没有 keyup
事件,该监听不会在任何时候被触发
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个问题解决了,我后面再提交吧,现在问题是窗口隐藏和关闭怎么判断,到时候如果成了一起提交,不成就直接close吧😥
if (input.key == "Escape") { | ||
try { | ||
if (config.escapeWindowWithInput && !config.preventEscape) { | ||
if (window.isClosable()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
能否直接使用window.close()
方法,close方法是模拟用户点击X
按钮,正常情况下的窗口,应该都包含X,都能使用户主动关闭,直接用close方法应该是可行的吧,目前测试,使用close方法关闭多重窗口,均正常处理,且重新打开时未出现异常。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接调用 window.close()
是可行的,但我想将两个功能放在一个模块内,方便后续调试和整理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
刚测试 子窗口关不掉,跟官方的不一致。
比如个人资料编辑页面。侧边栏管理页面。
😨😨麻了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emmm当我前面没说,还是继续研究要怎么实现这个功能吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我通过窗口的源码找到了相关的内容,有什么方法检测是否打开了对话框吗?
<div class="q-dialog lite-tools-vue-component vue-component" style="position: fixed; z-index: 4000;">
<div class="q-dialog-modal" style="position: inherit; background: var(--overlay_mask_standard);"></div>
<div class="modify-profile-dialog q-dialog-main lite-tools-vue-component vue-component" style="margin: auto 10px;">
<div class="q-dialog-header">
<div class="q-dialog-window-title">编辑资料</div><i class="q-svg-icon q-icon q-dialog-close lite-tools-vue-component vue-component" data-v-d4820ab3="" style="width: 20px; height: 20px; --234e3e61: var(--icon-primary);"><svg viewBox="0 0 24 24"><use xlink:href="/_upper_/resource/icons/close_24.svg#close_24"></use></svg></i>
</div>
<div class="q-dialog-body">
<div class="q-dialog-text-area">
<!---->
<div class="q-dialog-content">
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最简单的办法是在 DOM 中查找是否存在弹窗的 class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows新版本好像已经修复了这个bug。。。被官方背刺了,之前反馈的时候说是不修,现在又正常了。。。我这边关掉所有插件后测试是正常的,其他人可以帮忙测试一下是不是官方做了这个功能。 |
官方那边回复输入框有内容不会关闭。也就是说他们设计的是有内容不会关闭。 |
暂时关闭吧,不知道官方那边动态是什么 |
优化功能:QQ默认在输入框内有内容的时候,按下Esc键不会隐藏窗口。此功能就是忽略这一操作,只要按下Esc就会隐藏。同时考虑到原有功能“阻止 ESC 关闭窗口”可能会有冲突,所以在处理时,一旦开启了“阻止 ESC 关闭窗口”功能,该功能就会失效。
平时开发没使用过js,对这块很不熟,但是已经测试过正常处理,如果有什么不对的地方,非常希望能够提出来。