简体   繁体   English

Windows 7中使用Qt / QML应用程序的自定义触摸行为

[英]Custom Touch behavior in Windows 7 with Qt/QML application

I am developing a touch application for Windows 7 with Qt/QML. 我正在使用Qt / QML开发Windows 7的触摸应用程序。 The end-user-device has Windows 7's native touch behavior, ie: When touching the screen, a point appears on the last-touched-point, and when ending the physical touch, Windows puts that point on the now-touched point and runs in the on-clicked-Event. 最终用户设备具有Windows 7的本机触摸行为,即:当触摸屏幕时,最后触摸点上会出现一个点,当结束物理触摸时,Windows会将该点放在现在触摸的点上并运行在点击活动中。

Compared to the behavior one knows from standard Windows mouse-usage, this leads to a different behavior as soon as it comes to eg clicking some button: A mouse user will expect that the button changes color to the pressed-down-color when mouse button goes down, while the color changes to the default color again when the mouse button goes up. 与标准Windows鼠标使用中所知的行为相比,一旦点击某个按钮,就会导致不同的行为:当鼠标按钮时,鼠标用户将期望按钮将颜色更改为按下的颜色当鼠标按钮上升时,颜色会再次变为默认颜色。

In my application, I want to have a customized way of touch feedback: What is currently being touched should be marked using changed colors of buttons, imitating a "mouse goes down" when the actual physical touch begins and imitating a "mouse goes up" when the actual physical touch ends. 在我的应用程序中,我希望有一种自定义的触摸反馈方式:当前触摸的内容应使用更改的按钮颜色进行标记,在实际物理触摸开始时模仿“鼠标下降”并模仿“鼠标上升”当实际的物理触摸结束时。

My application will run fullscreen, so an actual possibility would be to change the system's behavior on application start and change it back to default on applications end. 我的应用程序将全屏运行,因此实际可能性是在应用程序启动时更改系统的行为,并在应用程序结束时将其更改回默认值。

Such a behavior would effectively be the same as the standard behavior on eg all Android devices I know. 这种行为实际上与我所知道的所有Android设备上的标准行为相同。

I searched through all the MouseArea and MultiPointTouchArea elements, trying to find a way to just make the click-reaction behavior different to the standard behavior. 我搜索了所有MouseArea和MultiPointTouchArea元素,试图找到一种方法来使点击反应行为与标准行为不同。 However I did not even find a way to capture the begin of the actual touch ... All the things which I want to happen at the begin of the touch actually happen when the touching ends. 然而,我甚至没有找到一种方法来捕捉实际触摸的开始...我想要在触摸开始时发生的所有事情实际上发生在触摸结束时。

Edit: It does not matter if I use a QML button or a mousearea plus the MouseArea.pressed property: Nothing will be "pressed" before the finger leaves the touch and the onClicked() even is called. 编辑:如果我使用QML按钮或鼠标区加上MouseArea.pressed属性并不重要:在手指离开触摸并且调用onClicked()之前,不会“按下”任何内容。

Possibly related: Adobe AIR: touch screen doesn't trigger mouse down event correctly - but I did not find a way to access the functions like Multitouch.inputMode (which are mentioned in the first reply) from a native Qt application. 可能相关: Adobe AIR:触摸屏不能正确触发鼠标按下事件 - 但是我没有找到从本机Qt应用程序访问Multitouch.inputMode(在第一个回复中提到)等功能的方法。

How can I achieve the described behavior for my application? 如何为我的应用程序实现所描述的行为?

The solution for this issue is to disable "Press and Hold" for the application. 此问题的解决方案是禁用应用程序的“按住”。 This is what can be done in a system-wide setting using ... Control Panel -> Pen and Touch -> Touch -> Press and Hold -> Settings -> uncheck 'Enable press and hold for right-clicking' 这是在系统范围设置中可以使用...控制面板 - >笔和触摸 - >触摸 - >按住 - >设置 - >取消选中“启用按住以右键单击”

The only solution I found to to this in native code can be found here: http://msdn.microsoft.com/en-us/library/ms812373.aspx 我在本机代码中找到的唯一解决方案可以在这里找到: http//msdn.microsoft.com/en-us/library/ms812373.aspx

I checked that this is at least still working for Windows 7. To get it working for QML, I searched for the QWindow* in QQmlApplicationEngine::rootObjects() and used its winId as a HWND. 我检查过这至少仍然适用于Windows 7.为了让它适用于QML,我在QQmlApplicationEngine :: rootObjects()中搜索了QWindow *并将其winId用作HWND。 With that HWND, I called the TogglePressAndHold function from the link before app.exec(). 使用该HWND,我在app.exec()之前从链接调用了TogglePressAndHold函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM