|
|
|
@ -105,20 +105,17 @@ namespace Avalonia.Controls |
|
|
|
{ |
|
|
|
if (control != null && control.IsVisible && control.GetVisualRoot() != null) |
|
|
|
{ |
|
|
|
if (s_popup == null) |
|
|
|
if (s_popup != null) |
|
|
|
{ |
|
|
|
s_popup = new PopupRoot |
|
|
|
{ |
|
|
|
Content = new ToolTip(), |
|
|
|
}; |
|
|
|
|
|
|
|
((ISetLogicalParent)s_popup).SetParent(control); |
|
|
|
throw new AvaloniaInternalException("Previous ToolTip not disposed."); |
|
|
|
} |
|
|
|
|
|
|
|
var cp = MouseDevice.Instance?.GetPosition(control); |
|
|
|
var position = control.PointToScreen(cp ?? new Point(0, 0)) + new Vector(0, 22); |
|
|
|
|
|
|
|
((ToolTip)s_popup.Content).Content = GetTip(control); |
|
|
|
s_popup = new PopupRoot(); |
|
|
|
((ISetLogicalParent)s_popup).SetParent(control); |
|
|
|
s_popup.Content = new ToolTip { Content = GetTip(control) }; |
|
|
|
s_popup.Position = position; |
|
|
|
s_popup.Show(); |
|
|
|
|
|
|
|
@ -148,9 +145,15 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
if (control == s_current) |
|
|
|
{ |
|
|
|
if (s_popup != null && s_popup.IsVisible) |
|
|
|
if (s_popup != null) |
|
|
|
{ |
|
|
|
s_popup.Hide(); |
|
|
|
// Clear the ToolTip's Content in case it has control content: this will
|
|
|
|
// reset its visual parent allowing it to be used again.
|
|
|
|
((ToolTip)s_popup.Content).Content = null; |
|
|
|
|
|
|
|
// Dispose of the popup.
|
|
|
|
s_popup.Dispose(); |
|
|
|
s_popup = null; |
|
|
|
} |
|
|
|
|
|
|
|
s_show.OnNext(null); |
|
|
|
|