NIM_Duilib_Framework icon indicating copy to clipboard operation
NIM_Duilib_Framework copied to clipboard

触摸屏如西沃上 不能通过触摸的方式 移动标题栏

Open shuilan0066 opened this issue 3 years ago • 3 comments

复现: 西沃 触摸屏 无法通过触摸方式 移动标题栏

shuilan0066 avatar Feb 25 '22 09:02 shuilan0066

复现: 西沃 触摸屏 无法通过触摸方式 移动标题栏

这个问题可能得麻烦您提供一下调试的信息了,在 TOUCH MOVE 相关的事件中增加一些打印来协助排查一下问题,因为我们这边很难弄到相关设备。

nmgwddj avatar Feb 25 '22 09:02 nmgwddj

经查, case WM_TOUCH: 这里没有判断点击的是否是标题栏 做如下修改后,就好了

` case WM_TOUCH: { unsigned int nNumInputs = (int)wParam; TOUCHINPUT* pInputs = new TOUCHINPUT[nNumInputs];

	// 只关心第一个触摸位置
	if (nNumInputs >= 1 && GetTouchInputInfoWrapper((HTOUCHINPUT)lParam, nNumInputs, pInputs, sizeof(TOUCHINPUT)))
	{
		if (pInputs[0].dwID != 0)
		{
			POINT pt;
			pt.x = TOUCH_COORD_TO_PIXEL(pInputs[0].x);
			pt.y = TOUCH_COORD_TO_PIXEL(pInputs[0].y);
			ScreenToClient(m_hWnd, &pt);

			//................判断是否标题栏
			ui::UiRect rc = GetCaptionRect();
			UiRect rcClient;
			::GetClientRect(GetHWND(), &rcClient);
			rcClient.Deflate(m_shadow.GetShadowCorner());

			UiRect rcCaption = GetCaptionRect();
			if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
				&& pt.y >= rcClient.top + rcCaption.top && pt.y < rcClient.top + rcCaption.bottom) {
				Control* pControl = FindControl(pt);
				if (pControl) {
					if (dynamic_cast<Button*>(pControl) || dynamic_cast<ButtonBox*>(pControl) || dynamic_cast<RichEdit*>(pControl))
						;
					else
					{
						CloseTouchInputHandleWrapper((HTOUCHINPUT)lParam);
						delete[] pInputs;
						break;
					}
				}
			}
			//..............................


			if (pInputs[0].dwFlags & TOUCHEVENTF_DOWN)
			{
				if (m_pEventClick != NULL || m_pEventPointer != NULL)
					break;

				::SetFocus(m_hWnd);
				m_ptLastTouchPos = pt;
				Control *pControl = FindControl(pt);
				if (pControl == NULL) break;
				if (pControl->GetWindow() != this) break;
				m_pEventTouch = pControl;
				pControl->SetFocus();
				SetCapture();

				pControl->HandleMessageTemplate(kEventTouchDown, 0, lParam, 0, pt);
			}
			else if (pInputs[0].dwFlags & TOUCHEVENTF_MOVE)
			{
				if (m_pEventClick != NULL || m_pEventPointer != NULL)
					break;

				if (m_ptLastTouchPos.x == pt.x && m_ptLastTouchPos.y == pt.y)
					break;

				m_ptLastTouchPos = pt;
				if (m_pEventTouch == NULL) break;

				if (!HandleMouseEnterLeave(pt, wParam, lParam)) break;

				m_pEventTouch->HandleMessageTemplate(kEventTouchMove, 0, 0, 0, pt);
			}
			else if (pInputs[0].dwFlags & TOUCHEVENTF_UP)
			{
				m_ptLastTouchPos = pt;
				ReleaseCapture();
				if (m_pEventTouch == NULL) break;

				m_pEventTouch->HandleMessageTemplate(kEventTouchUp, 0, lParam, 0, pt);
				m_pEventTouch = NULL;
			}
		}
	}

	CloseTouchInputHandleWrapper((HTOUCHINPUT)lParam);
	delete[] pInputs;
}
	break;`

shuilan0066 avatar Mar 03 '22 07:03 shuilan0066

经查, case WM_TOUCH: 这里没有判断点击的是否是标题栏 做如下修改后,就好了

` case WM_TOUCH: { unsigned int nNumInputs = (int)wParam; TOUCHINPUT* pInputs = new TOUCHINPUT[nNumInputs];

	// 只关心第一个触摸位置
	if (nNumInputs >= 1 && GetTouchInputInfoWrapper((HTOUCHINPUT)lParam, nNumInputs, pInputs, sizeof(TOUCHINPUT)))
	{
		if (pInputs[0].dwID != 0)
		{
			POINT pt;
			pt.x = TOUCH_COORD_TO_PIXEL(pInputs[0].x);
			pt.y = TOUCH_COORD_TO_PIXEL(pInputs[0].y);
			ScreenToClient(m_hWnd, &pt);

			//................判断是否标题栏
			ui::UiRect rc = GetCaptionRect();
			UiRect rcClient;
			::GetClientRect(GetHWND(), &rcClient);
			rcClient.Deflate(m_shadow.GetShadowCorner());

			UiRect rcCaption = GetCaptionRect();
			if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
				&& pt.y >= rcClient.top + rcCaption.top && pt.y < rcClient.top + rcCaption.bottom) {
				Control* pControl = FindControl(pt);
				if (pControl) {
					if (dynamic_cast<Button*>(pControl) || dynamic_cast<ButtonBox*>(pControl) || dynamic_cast<RichEdit*>(pControl))
						;
					else
					{
						CloseTouchInputHandleWrapper((HTOUCHINPUT)lParam);
						delete[] pInputs;
						break;
					}
				}
			}
			//..............................


			if (pInputs[0].dwFlags & TOUCHEVENTF_DOWN)
			{
				if (m_pEventClick != NULL || m_pEventPointer != NULL)
					break;

				::SetFocus(m_hWnd);
				m_ptLastTouchPos = pt;
				Control *pControl = FindControl(pt);
				if (pControl == NULL) break;
				if (pControl->GetWindow() != this) break;
				m_pEventTouch = pControl;
				pControl->SetFocus();
				SetCapture();

				pControl->HandleMessageTemplate(kEventTouchDown, 0, lParam, 0, pt);
			}
			else if (pInputs[0].dwFlags & TOUCHEVENTF_MOVE)
			{
				if (m_pEventClick != NULL || m_pEventPointer != NULL)
					break;

				if (m_ptLastTouchPos.x == pt.x && m_ptLastTouchPos.y == pt.y)
					break;

				m_ptLastTouchPos = pt;
				if (m_pEventTouch == NULL) break;

				if (!HandleMouseEnterLeave(pt, wParam, lParam)) break;

				m_pEventTouch->HandleMessageTemplate(kEventTouchMove, 0, 0, 0, pt);
			}
			else if (pInputs[0].dwFlags & TOUCHEVENTF_UP)
			{
				m_ptLastTouchPos = pt;
				ReleaseCapture();
				if (m_pEventTouch == NULL) break;

				m_pEventTouch->HandleMessageTemplate(kEventTouchUp, 0, lParam, 0, pt);
				m_pEventTouch = NULL;
			}
		}
	}

	CloseTouchInputHandleWrapper((HTOUCHINPUT)lParam);
	delete[] pInputs;
}
	break;`

您可以将改动通过 PR 方式提交到 develop 分支。我们会有人来进行拉取测试,感谢您发现并解决 NIM duilib 的不足。

nmgwddj avatar Mar 03 '22 08:03 nmgwddj