Fixed a problem with Tooltip that would also show up if it was blocked on top. 修复Tooltip在上层有遮挡还会显示的问题#74

This commit is contained in:
monitor1394
2020-07-16 09:16:36 +08:00
parent 64178ef88d
commit fe1c11fc5d
4 changed files with 17 additions and 2 deletions

View File

@@ -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`参数配置偏移

View File

@@ -45,10 +45,15 @@ namespace XCharts
public Rect graphRect { get { return m_GraphRect; } }
/// <summary>
/// The postion of pointer.
/// 鼠标位置
/// 鼠标位置
/// </summary>
public Vector2 pointerPos { get; protected set; }
/// <summary>
/// Whether the mouse pointer is in the chart.
/// 鼠标是否在图表内。
/// </summary>
public bool isPointerInChart { get; protected set; }
/// <summary>
/// 警告信息。
/// </summary>
public string warningInfo { get; protected set; }

View File

@@ -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())
{

View File

@@ -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);
}