Skip to content

Commit a012639

Browse files
bearkrozele
authored andcommitted
Add simple tooltips to views. (microsoft#1568)
1 parent 705871b commit a012639

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

Libraries/Components/View/ViewPropTypes.windows.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export type ViewProps = {
8282
shouldRasterizeIOS?: bool,
8383
collapsable?: bool,
8484
needsOffscreenAlphaCompositing?: bool,
85+
tooltip?: string,
8586
} & TVViewProps;
8687

8788
module.exports = {
@@ -497,4 +498,12 @@ module.exports = {
497498
'scale',
498499
'all',
499500
])),
501+
502+
/**
503+
* A short string description that will appear in a tooltip if the user
504+
* hovers their pointer over the View for a short duration.
505+
*
506+
* @platform windows
507+
*/
508+
tooltip: PropTypes.string,
500509
};

ReactWindows/ReactNative.Net46/UIManager/BaseViewManager.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ public void SetTestId(TFrameworkElement view, string testId)
112112
AutomationProperties.SetAutomationId(view, testId ?? "");
113113
}
114114

115+
/// <summary>
116+
/// Sets a tooltip for the view.
117+
/// </summary>
118+
/// <param name="view">The view instance.</param>
119+
/// <param name="tooltip">String to display in the tooltip.</param>
120+
[ReactProp("tooltip")]
121+
public void SetTooltip(TFrameworkElement view, string tooltip)
122+
{
123+
ToolTipService.SetToolTip(view, tooltip);
124+
}
125+
115126
/// <summary>
116127
/// Called when view is detached from view hierarchy and allows for
117128
/// additional cleanup by the <see cref="IViewManager"/> subclass.

ReactWindows/ReactNative/UIManager/BaseViewManager.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ public void SetTestId(TFrameworkElement view, string testId)
177177
AutomationProperties.SetAutomationId(view, testId ?? "");
178178
}
179179

180+
/// <summary>
181+
/// Sets a tooltip for the view.
182+
/// </summary>
183+
/// <param name="view">The view instance.</param>
184+
/// <param name="tooltip">String to display in the tooltip.</param>
185+
[ReactProp("tooltip")]
186+
public void SetTooltip(TFrameworkElement view, string tooltip)
187+
{
188+
ToolTipService.SetToolTip(view, tooltip);
189+
}
190+
180191
/// <summary>
181192
/// Called when view is detached from view hierarchy and allows for
182193
/// additional cleanup by the <see cref="IViewManager"/> subclass.

0 commit comments

Comments
 (0)