MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Show

Method Show

Source/Engine/UI/GUI/Tooltip.cs:61–125  ·  view source on GitHub ↗

Shows tooltip over given control. The parent control to attach to it. Popup menu origin location in parent control coordinates. Tooltip target area of interest.

(Control target, Float2 location, Rectangle targetArea)

Source from the content-addressed store, hash-verified

59 /// <param name="location">Popup menu origin location in parent control coordinates.</param>
60 /// <param name="targetArea">Tooltip target area of interest.</param>
61 public void Show(Control target, Float2 location, Rectangle targetArea)
62 {
63 if (target == null)
64 throw new ArgumentNullException();
65
66 // Ensure to be closed
67 Hide();
68
69 // Block showing tooltips when application is not focused
70 if (!Platform.HasFocus)
71 return;
72
73 // Unlock and perform controls update
74 UnlockChildrenRecursive();
75 PerformLayout();
76
77 var parentWin = target.Root;
78 if (parentWin == null)
79 return;
80
81 // Showing a popup window might bring up the parent window on top
82 if (!parentWin.IsFocused)
83 return;
84
85 // Calculate popup direction and initial location
86 var dpiScale = target.RootWindow.DpiScale;
87 var dpiSize = Size * dpiScale;
88 var locationWS = target.PointToWindow(location);
89 var locationSS = parentWin.PointToScreen(locationWS);
90 var mousePos = Input.MouseScreenPosition;
91 _showTarget = target;
92 //WrapPosition(ref locationSS);
93 WrapPosition(ref mousePos, 10);
94 locationSS = mousePos + TooltipOffset;
95
96 // Create window
97 var desc = CreateWindowSettings.Default;
98 desc.StartPosition = WindowStartPosition.Manual;
99 desc.Position = locationSS;
100 desc.Size = dpiSize;
101 desc.Fullscreen = false;
102 desc.HasBorder = false;
103 desc.SupportsTransparency = false;
104 desc.ShowInTaskbar = false;
105 desc.ActivateWhenFirstShown = false;
106 desc.AllowInput = false;
107 desc.AllowMinimize = false;
108 desc.AllowMaximize = false;
109 desc.AllowDragAndDrop = false;
110 desc.IsTopmost = true;
111 desc.Type = WindowType.Tooltip;
112 desc.Title = "Tooltip";
113 desc.HasSizingFrame = false;
114 desc.ShowAfterFirstPaint = true;
115 desc.Parent = parentWin.RootWindow.Window;
116 _window = Platform.CreateWindow(ref desc);
117 if (_window == null)
118 throw new InvalidOperationException("Failed to create tooltip window.");

Callers 2

PresentMethod · 0.45
BeforeRunMethod · 0.45

Calls 4

PointToWindowMethod · 0.80
PointToScreenMethod · 0.45
CreateWindowMethod · 0.45
OnTooltipShownMethod · 0.45

Tested by

no test coverage detected