Skip to content

Conversation

@RainYangty
Copy link
Contributor

@RainYangty RainYangty commented Sep 20, 2025

a8f26cb56f68d59ab5f34e4ef069e479

Summary

This pull request introduces a custom instant, mouse-following tooltip feature for macOS (AppKit) views. This implementation uses an NSViewRepresentable bridge to AppKit, allowing us to display a custom NSWindow immediately 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

  1. New File: MeoAsstMac/Views/InstantTooltip.swift:

    • Adds an AppKitTooltipModifier and a corresponding TooltipView (NSViewRepresentable).
    • Implements a custom Coordinator to handle NSTrackingArea events (mouseEntered, mouseMoved, mouseExited).
    • Creates and manages a borderless NSWindow to host the SwiftUI tooltip content, enabling custom styling (e.g., padding, rounded background, shadows).
    • Includes logic to ensure the tooltip window stays within the screen boundaries.
    • Adds a 10-second auto-hide timer for the tooltip.
    • Provides the easy-to-use .instantTooltip<TooltipContent: View>(@ViewBuilder content: () -> TooltipContent) View extension.
  2. Integration of .instantTooltip:

    • Replaces the standard .help() modifier with the new .instantTooltip in various files where applicable, including: CopilotContent.swift, CopilotDetail.swift, TaskDetail.swift, TasksContent.swift, UtilityContent.swift, and LogView.swift.
    • This ensures a consistent and enhanced visual feedback experience for buttons and controls across the application.

Files Affected

  • MeoAsstMac/Navigation/CopilotContent.swift
  • MeoAsstMac/Navigation/CopilotDetail.swift
  • MeoAsstMac/Navigation/TaskDetail.swift
  • MeoAsstMac/Navigation/TasksContent.swift
  • MeoAsstMac/Navigation/UtilityContent.swift
  • MeoAsstMac/Views/InstantTooltip.swift (New Feature)
  • MeoAsstMac/Views/LogView.swift


摘要

本次拉取请求(PR)引入了一项自定义的即时、鼠标跟随工具提示功能,专用于 macOS (AppKit) 视图。此实现通过一个 NSViewRepresentable 桥接到 AppKit,使我们能够在鼠标悬停时立即显示一个自定义的 NSWindow,并让它实时跟随鼠标的位置。

这项新功能取代了标准的系统工具提示功能,并已在多个关键组件中投入使用,以提供更具响应性和可定制的用户体验。

主要更改

  1. 新增文件:MeoAsstMac/Views/InstantTooltip.swift:

    • 添加了 AppKitTooltipModifier 和对应的 TooltipView (NSViewRepresentable)。
    • 实现了一个自定义的 Coordinator 来处理 NSTrackingArea 事件(mouseEnteredmouseMovedmouseExited)。
    • 创建并管理一个无边框的 NSWindow 来承载 SwiftUI 工具提示内容,从而实现自定义样式(例如内边距、圆角背景、阴影)。
    • 包含了确保工具提示窗口停留在屏幕边界内的逻辑。
    • 新增了一个 10 秒自动隐藏计时器
    • 提供了易于使用的 .instantTooltip<TooltipContent: View>(@ViewBuilder content: () -> TooltipContent) View 扩展。
  2. 集成 .instantTooltip:

    • 在适用范围,将标准 .help() 修饰符替换为新的 .instantTooltip,涉及文件包括:CopilotContent.swiftCopilotDetail.swiftTaskDetail.swiftTasksContent.swiftUtilityContent.swiftLogView.swift
    • 这确保了应用程序中按钮和控件提供统一且增强的视觉反馈体验。

受影响的文件

  • MeoAsstMac/Navigation/CopilotContent.swift
  • MeoAsstMac/Navigation/CopilotDetail.swift
  • MeoAsstMac/Navigation/TaskDetail.swift
  • MeoAsstMac/Navigation/TasksContent.swift
  • MeoAsstMac/Navigation/UtilityContent.swift
  • MeoAsstMac/Views/InstantTooltip.swift (新功能)
  • MeoAsstMac/Views/LogView.swift

@RainYangty
Copy link
Contributor Author

原来那个conflict太多了,刚好把pr拆分一下

@RainYangty
Copy link
Contributor Author

#57

@RainYangty RainYangty changed the title feat: 添加控件悬浮提示 feat: Implement Instant Mouse-Following Tooltip Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant