From a208ac59068793e85a37b00786c0dcc1bae90261 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 16 Jul 2020 09:16:36 +0800 Subject: [PATCH] =?UTF-8?q?Fixed=20a=20problem=20with=20`Tooltip`=20that?= =?UTF-8?q?=20would=20also=20show=20up=20if=20it=20was=20blocked=20on=20to?= =?UTF-8?q?p.=20=E4=BF=AE=E5=A4=8D`Tooltip`=E5=9C=A8=E4=B8=8A=E5=B1=82?= =?UTF-8?q?=E6=9C=89=E9=81=AE=E6=8C=A1=E8=BF=98=E4=BC=9A=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98#74?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ Runtime/API/BaseGraph_API.cs | 7 ++++++- Runtime/Internal/BaseChart.cs | 2 +- Runtime/Internal/BaseGraphic.cs | 8 ++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ad165cc..b30e2e3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # 更新日志 +* (2020.07.16) Fixed a problem with `Tooltip` that would also show up if it was blocked on top. #74 + 修复`Tooltip`在上层有遮挡还会显示的问题#74 * (2020.07.08) 优化`Scatter`类型`Serie`支持`Log`轴#70 * (2020.07.07) 修复`SerieLabel`位置错乱的问题 * (2020.07.07) 增加`Tooltip`的`offset`参数配置偏移 diff --git a/Runtime/API/BaseGraph_API.cs b/Runtime/API/BaseGraph_API.cs index 359c3e0f..22e4015f 100644 --- a/Runtime/API/BaseGraph_API.cs +++ b/Runtime/API/BaseGraph_API.cs @@ -45,10 +45,15 @@ namespace XCharts public Rect graphRect { get { return m_GraphRect; } } /// /// The postion of pointer. - /// 鼠标位置 + /// 鼠标位置。 /// public Vector2 pointerPos { get; protected set; } /// + /// Whether the mouse pointer is in the chart. + /// 鼠标是否在图表内。 + /// + public bool isPointerInChart { get; protected set; } + /// /// 警告信息。 /// public string warningInfo { get; protected set; } diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index b55f0262..fdbfb046 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -543,7 +543,7 @@ namespace XCharts private void CheckTooltip() { - if (!m_Tooltip.show || !m_Tooltip.runtimeInited) + if (!isPointerInChart || !m_Tooltip.show || !m_Tooltip.runtimeInited) { if (m_Tooltip.IsActive()) { diff --git a/Runtime/Internal/BaseGraphic.cs b/Runtime/Internal/BaseGraphic.cs index 6ab228d4..82fe8e5d 100644 --- a/Runtime/Internal/BaseGraphic.cs +++ b/Runtime/Internal/BaseGraphic.cs @@ -160,6 +160,7 @@ namespace XCharts if (m_ForceOpenRaycastTarget) raycastTarget = true; if (IsNeedCheckPointerPos()) { + raycastTarget = true; if (canvas == null) return; Vector2 local; var cam = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvas.worldCamera; @@ -173,6 +174,10 @@ namespace XCharts pointerPos = local; } } + else + { + raycastTarget = false; + } } protected virtual bool IsNeedCheckPointerPos() @@ -215,6 +220,7 @@ namespace XCharts public virtual void OnPointerClick(PointerEventData eventData) { + Debug.LogError("click"); if (m_OnPointerClick != null) m_OnPointerClick(this, eventData); } @@ -230,11 +236,13 @@ namespace XCharts public virtual void OnPointerEnter(PointerEventData eventData) { + isPointerInChart = true; if (m_OnPointerEnter != null) m_OnPointerEnter(this, eventData); } public virtual void OnPointerExit(PointerEventData eventData) { + isPointerInChart = false; if (m_OnPointerExit != null) m_OnPointerExit(this, eventData); }