fix(menubar): 修复 hover 时滚动不停止 - #23
Merged
Merged
Conversation
cbd3831(切 NSImage 渲染)把菜单栏 ticker 从 button 子视图改成离屏渲染后, hover 检测改成在 button 上挂 NSTrackingArea —— 但状态栏按钮上的 tracking area 实测从不派发 mouseEntered/Exited(日志验证 ENTER/EXIT 计数为 0), 导致 tickerView.hovered 永远为 false,滚动 / 轮播在 hover 时不暂停。 改用全局 + 本地 mouseMoved 监听,按 NSEvent.mouseLocation 是否落在状态栏 按钮的屏幕矩形内来设 hovered。鼠标移动的全局监听不需要辅助功能权限。 顺带删除不再使用的 HoverProxy.swift。
|
This run was cancelled 🛑 The workflow was cancelled before completion. Please check the link below for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

问题
鼠标悬停在菜单栏滚动 / 轮播 ticker 上时,滚动不会暂停(
pauseOnHover失效)。根因(回归)
cbd3831(切到 NSImage 离屏渲染、修「app 不激活时颜色变浅」)把 ticker 从button.addSubview(tickerView)改成离屏渲染贴button.image。view 不再在窗口层级里,于是 hover 检测改成在statusItem.button上挂NSTrackingArea+HoverProxy。但状态栏按钮上的
NSTrackingArea实测从不派发mouseEntered/Exited(临时加日志验证:ENTER/EXIT 计数均为 0)→tickerView.hovered永远false→step()里的if pauseOnHover && hovered { return }从不触发 → 滚动不停。修复
改用 全局 + 本地
mouseMoved监听,按NSEvent.mouseLocation是否落在状态栏按钮的屏幕矩形内来设tickerView.hovered,与离屏渲染架构解耦、可靠得多:NSTrackingArea及HoverProxy.swift。deinit里移除监听。验证