feat: Implement Instant Mouse-Following Tooltip - #62
Open
RainYangty wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
原来那个conflict太多了,刚好把pr拆分一下 |
Contributor
Author
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.
Summary
This pull request introduces a custom instant, mouse-following tooltip feature for macOS (AppKit) views. This implementation uses an
NSViewRepresentablebridge to AppKit, allowing us to display a customNSWindowimmediately upon mouse-over, and have it track the mouse position.The new functionality replaces the standard system tooltip functionality and is used across several key components to provide a more responsive and customizable user experience.
Key Changes
New File:
MeoAsstMac/Views/InstantTooltip.swift:AppKitTooltipModifierand a correspondingTooltipView(NSViewRepresentable).Coordinatorto handleNSTrackingAreaevents (mouseEntered,mouseMoved,mouseExited).NSWindowto host the SwiftUI tooltip content, enabling custom styling (e.g., padding, rounded background, shadows)..instantTooltip<TooltipContent: View>(@ViewBuilder content: () -> TooltipContent)Viewextension.Integration of
.instantTooltip:.help()modifier with the new.instantTooltipin various files where applicable, including:CopilotContent.swift,CopilotDetail.swift,TaskDetail.swift,TasksContent.swift,UtilityContent.swift, andLogView.swift.Files Affected
MeoAsstMac/Navigation/CopilotContent.swiftMeoAsstMac/Navigation/CopilotDetail.swiftMeoAsstMac/Navigation/TaskDetail.swiftMeoAsstMac/Navigation/TasksContent.swiftMeoAsstMac/Navigation/UtilityContent.swiftMeoAsstMac/Views/InstantTooltip.swift(New Feature)MeoAsstMac/Views/LogView.swift摘要
本次拉取请求(PR)引入了一项自定义的即时、鼠标跟随工具提示功能,专用于 macOS (AppKit) 视图。此实现通过一个
NSViewRepresentable桥接到 AppKit,使我们能够在鼠标悬停时立即显示一个自定义的NSWindow,并让它实时跟随鼠标的位置。这项新功能取代了标准的系统工具提示功能,并已在多个关键组件中投入使用,以提供更具响应性和可定制的用户体验。
主要更改
新增文件:
MeoAsstMac/Views/InstantTooltip.swift:AppKitTooltipModifier和对应的TooltipView(NSViewRepresentable)。Coordinator来处理NSTrackingArea事件(mouseEntered、mouseMoved、mouseExited)。NSWindow来承载 SwiftUI 工具提示内容,从而实现自定义样式(例如内边距、圆角背景、阴影)。.instantTooltip<TooltipContent: View>(@ViewBuilder content: () -> TooltipContent)View扩展。集成
.instantTooltip:.help()修饰符替换为新的.instantTooltip,涉及文件包括:CopilotContent.swift、CopilotDetail.swift、TaskDetail.swift、TasksContent.swift、UtilityContent.swift和LogView.swift。受影响的文件
MeoAsstMac/Navigation/CopilotContent.swiftMeoAsstMac/Navigation/CopilotDetail.swiftMeoAsstMac/Navigation/TaskDetail.swiftMeoAsstMac/Navigation/TasksContent.swiftMeoAsstMac/Navigation/UtilityContent.swiftMeoAsstMac/Views/InstantTooltip.swift(新功能)MeoAsstMac/Views/LogView.swift