예제 #1
0
void Window::ElementSetMouseCursor(UIElement* element)
{
	if (element == nullptr)
	{
		raise(ArgumentNullException());
	}

	if (element->get_IsMouseDirectlyOver())
	{
		Cursor* pCursor = element->get_Cursor();
		if (pCursor)
		{
			::SetCursor(pCursor->GetHCursor());

			if (!showCursor)
			{
				showCursor = true;
				::ShowCursor(TRUE);
			}
		}
		else
		{
			if (showCursor)
			{
				::ShowCursor(FALSE);
				showCursor = false;
			}
		}
	}
}
예제 #2
0
bool PlatformWindowSite::OnSetCursor(UINT hitTest, POINT screenMousePos)
{
	if (hitTest == HTCLIENT)
	{
		gm::PointF clientMousePos(screenMousePos.x, screenMousePos.y);
		ScreenToClient(m_platformWindow->get_Handle(), (POINT*)&clientMousePos);

		IInputElement* hitElement = nullptr;

		if (m_MouseCaptureElement)
		{
			hitElement = m_MouseCaptureElement;
		}
		else
		{
			//Visual* child = get_Child();
			UIElement* child = GetRootElement();

			if (child)
			{
				hitElement = child->HitTest_(clientMousePos);
			}

		//	hitElement = child;
		}

		if (hitElement == nullptr)
		{
			hitElement = dynamic_cast<IInputElement*>(this);
		}

		if (hitElement)
		{
			/*
			MouseEventArgs* args = new MouseEventArgs(nullptr, 0);
			args->set_RoutedEvent(UIElement::MouseMoveEvent);
			args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
			args->m_clientpos = clientMousePos;

			hitElement->RaiseEvent(args);
			*/
			Cursor* pCursor = dynamic_cast<UIElement*>(hitElement)->get_Cursor();
			if (pCursor)
			{
				SetCursor(pCursor->GetHCursor());
				if (!showCursor)
				{
					showCursor = true;
					::ShowCursor(TRUE);
				}
				return true;
			}
			else
			{
				if (showCursor)
				{
					showCursor = false;
					::ShowCursor(FALSE);
				}
			}
		}
	}

	return false;
}