Esempio n. 1
0
        internal static void SetTooltip(float mouseX, float mouseY)
        {
            //mouseX,mouseY are screen relative.
            GUIView view = GUIView.mouseOverView;

            if (view != null && view.visualTree != null && view.visualTree.panel != null)
            {
                var panel = view.visualTree.panel;

                // Pick expect view relative coordinates.
                VisualElement target = panel.Pick(new Vector2(mouseX, mouseY) - view.screenPosition.position);
                if (target != null)
                {
                    using (var tooltipEvent = TooltipEvent.GetPooled())
                    {
                        tooltipEvent.target  = target;
                        tooltipEvent.tooltip = null;
                        tooltipEvent.rect    = Rect.zero;
                        view.visualTree.panel.dispatcher.DispatchEvent(tooltipEvent, panel);

                        if (!string.IsNullOrEmpty(tooltipEvent.tooltip))
                        {
                            Rect rect = tooltipEvent.rect;
                            rect.position += view.screenPosition.position; //SetMouseTooltip expects Screen relative coordinates.

                            GUIStyle.SetMouseTooltip(tooltipEvent.tooltip, rect);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        internal static void SetTooltip(float mouseX, float mouseY)
        {
            GUIView mouseOverView = GUIView.mouseOverView;

            if (mouseOverView != null && mouseOverView.visualTree != null && mouseOverView.visualTree.panel != null)
            {
                IPanel        panel         = mouseOverView.visualTree.panel;
                VisualElement visualElement = panel.Pick(new Vector2(mouseX, mouseY) - mouseOverView.screenPosition.position);
                if (visualElement != null)
                {
                    using (TooltipEvent pooled = EventBase <TooltipEvent> .GetPooled())
                    {
                        pooled.target  = visualElement;
                        pooled.tooltip = null;
                        pooled.rect    = Rect.zero;
                        mouseOverView.visualTree.panel.dispatcher.DispatchEvent(pooled, panel);
                        if (!string.IsNullOrEmpty(pooled.tooltip))
                        {
                            Rect rect = pooled.rect;
                            rect.position += mouseOverView.screenPosition.position;
                            GUIStyle.SetMouseTooltip(pooled.tooltip, rect);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 private void OnTooltip(TooltipEvent e)
 {
     e.tooltip = this.tooltip;
     e.rect    = base.worldBound;
     e.StopPropagation();
 }
Esempio n. 4
0
 void OnTooltip(TooltipEvent e)
 {
     e.tooltip = tooltip;
     e.rect    = worldBound;
     e.StopPropagation();
 }