-
Notifications
You must be signed in to change notification settings - Fork 998
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support keyboard tooltips in
TreeNode
(#4466)
- Loading branch information
1 parent
661239d
commit 77dcb4f
Showing
12 changed files
with
870 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
~override System.Windows.Forms.TreeView.OnGotFocus(System.EventArgs e) -> void | ||
~override System.Windows.Forms.TreeView.OnLostFocus(System.EventArgs e) -> void |
This file contains 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
This file contains 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
This file contains 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
66 changes: 66 additions & 0 deletions
66
src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.IKeyboardToolTip.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Drawing; | ||
|
||
namespace System.Windows.Forms | ||
{ | ||
public partial class TreeNode : IKeyboardToolTip | ||
{ | ||
bool IKeyboardToolTip.AllowsChildrenToShowToolTips() => AllowToolTips; | ||
|
||
bool IKeyboardToolTip.AllowsToolTip() => true; | ||
|
||
bool IKeyboardToolTip.CanShowToolTipsNow() => AllowToolTips; | ||
|
||
string IKeyboardToolTip.GetCaptionForTool(ToolTip toolTip) => ToolTipText; | ||
|
||
Rectangle IKeyboardToolTip.GetNativeScreenRectangle() => RectangleToScreen(Bounds); | ||
|
||
IList<Rectangle> IKeyboardToolTip.GetNeighboringToolsRectangles() | ||
{ | ||
TreeNode nextNode = NextVisibleNode; | ||
TreeNode prevNode = PrevVisibleNode; | ||
List<Rectangle> neighboringRectangles = new List<Rectangle>(); | ||
|
||
if (nextNode is not null) | ||
{ | ||
neighboringRectangles.Add(RectangleToScreen(nextNode.Bounds)); | ||
} | ||
|
||
if (prevNode is not null) | ||
{ | ||
neighboringRectangles.Add(RectangleToScreen(prevNode.Bounds)); | ||
} | ||
|
||
return neighboringRectangles; | ||
} | ||
|
||
IWin32Window IKeyboardToolTip.GetOwnerWindow() => TreeView; | ||
|
||
bool IKeyboardToolTip.HasRtlModeEnabled() => TreeView?.RightToLeft == RightToLeft.Yes; | ||
|
||
bool IKeyboardToolTip.IsBeingTabbedTo() => Control.AreCommonNavigationalKeysDown(); | ||
|
||
bool IKeyboardToolTip.IsHoveredWithMouse() => TreeView?.AccessibilityObject.Bounds.Contains(Control.MousePosition) ?? false; | ||
|
||
void IKeyboardToolTip.OnHooked(ToolTip toolTip) => OnKeyboardToolTipHook(toolTip); | ||
|
||
void IKeyboardToolTip.OnUnhooked(ToolTip toolTip) => OnKeyboardToolTipUnhook(toolTip); | ||
|
||
bool IKeyboardToolTip.ShowsOwnToolTip() => AllowToolTips; | ||
|
||
private bool AllowToolTips => TreeView?.ShowNodeToolTips ?? false; | ||
|
||
internal virtual void OnKeyboardToolTipHook(ToolTip toolTip) { } | ||
|
||
internal virtual void OnKeyboardToolTipUnhook(ToolTip toolTip) { } | ||
|
||
private Rectangle RectangleToScreen(Rectangle bounds) | ||
{ | ||
return TreeView?.RectangleToScreen(bounds) ?? Rectangle.Empty; | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.