-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add Delay and Duration properties to ToolTip functionality #29864
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
Conversation
mattleibow
left a comment
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.
Therte is no platform implementation. PLease make sure it works. Here is the code that runs:
Windows:
maui/src/Core/src/Platform/Windows/ViewExtensions.cs
Lines 270 to 273 in 56a432d
| public static void UpdateToolTip(this FrameworkElement platformView, ToolTip? tooltip) | |
| { | |
| ToolTipService.SetToolTip(platformView, tooltip?.Content); | |
| } |
macOS:
maui/src/Core/src/Platform/iOS/ViewExtensions.cs
Lines 633 to 655 in 56a432d
| public static void UpdateToolTip(this UIView platformView, ToolTip? tooltip) | |
| { | |
| // UpdateToolTips were added in 15.0 for both iOS and MacCatalyst | |
| if (OperatingSystem.IsMacCatalystVersionAtLeast(15) | |
| || OperatingSystem.IsIOSVersionAtLeast(15)) | |
| { | |
| string? text = tooltip?.Content?.ToString(); | |
| var interaction = platformView.GetToolTipInteraction(); | |
| if (interaction is null) | |
| { | |
| if (!string.IsNullOrEmpty(text)) | |
| { | |
| interaction = new UIToolTipInteraction(text); | |
| platformView.AddInteraction(interaction); | |
| } | |
| } | |
| else | |
| { | |
| interaction.DefaultToolTip = text; | |
| } | |
| } | |
| } |
Android:
maui/src/Core/src/Platform/Android/ViewExtensions.cs
Lines 430 to 434 in 56a432d
| public static void UpdateToolTip(this AView view, ToolTip? tooltip) | |
| { | |
| string? text = tooltip?.Content?.ToString(); | |
| TooltipCompat.SetTooltipText(view, text); | |
| } |
Please look at the docs on microsoft learn on how to implement.
|
There is no platform implementation. Please make sure it works. Here is the code that runs: Windows: maui/src/Core/src/Platform/Windows/ViewExtensions.cs Lines 270 to 273 in 56a432d
macOS: maui/src/Core/src/Platform/iOS/ViewExtensions.cs Lines 633 to 655 in 56a432d
Android: maui/src/Core/src/Platform/Android/ViewExtensions.cs Lines 430 to 434 in 56a432d
Please look at the docs on microsoft learn or the platform docs on how to implement. |
Platform-specific implementations have been added in commit db738eb. Windows has full support using ToolTipService.SetInitialShowDelay() and SetShowDuration() APIs. iOS/macOS and Android maintain basic tooltip functionality, with platform API limitations documented - UIToolTipInteraction and TooltipCompat don't provide built-in delay/duration properties without custom implementation. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
/azp run MAUI-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Got some build errors: |
... Fixed the PublicAPI analyzer errors by adding the new ToolTip.Delay and ToolTip.Duration properties to the PublicAPI.Unshipped.txt files for all target frameworks. The errors were caused by the new properties not being declared in the public API surface. Added entries for Delay.get, Delay.set, Duration.get, and Duration.set in commit 3729fdc. |
mattleibow
left a comment
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.
Looks good, please revert all the chnages to the src/Templates files. This is not meant to be checked in.
All changes to src/Templates files have been reverted in commit f3a8b63. The core ToolTip functionality remains intact while the unwanted template changes have been removed. |
|
Please rebase the branch, take changes from main for the Unshipped files |
Branch has been rebased on main and conflicts in PublicAPI.Unshipped.txt files have been resolved. The ToolTip properties are now properly included alongside all the latest main branch changes. Commit 9fdaab90. |
Co-authored-by: mattleibow <[email protected]>
Co-authored-by: mattleibow <[email protected]>
Co-authored-by: mattleibow <[email protected]>
Co-authored-by: mattleibow <[email protected]>
f3a8b63 to
eac9321
Compare
This PR adds support for ToolTip Delay and Duration properties as requested in the issue, allowing developers to control tooltip timing behavior.
Changes Made
DelayandDurationproperties to theToolTipclass as nullable integers (int?) to represent optional timing values in millisecondsDelayPropertyandDurationPropertyas bindable attached properties inToolTipPropertiesfollowing the same pattern as existing attached propertiesGetDelay,SetDelay,GetDuration,SetDurationfor accessing the attached propertiesGetToolTipinternal method to populate the new properties from attached properties when creating ToolTip instancesToolTipPropertiesTests.csto verify all functionality works correctlyAPI Usage
Developers can now use the following APIs as requested in the issue:
Programmatic Usage:
XAML Usage:
Implementation Details
SemanticPropertiesand other attached property implementationsIToolTipElement.ToolTipviaToolTipProperties.GetToolTip(this)This enables the use case described in the issue where users can control tooltip timing to balance discoverability with usability - showing tooltips with appropriate delays so they don't appear immediately on every hover once users are familiar with the interface.
Fixes #29416.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.