在 QtWebkit 中禁用拖放

发布于 2024-08-17 06:22:59 字数 542 浏览 15 评论 0原文

我正在尝试使用 Qt 的 WebKit 为应用程序创建 HTML GUI...到目前为止,一切都很顺利,只是有一个小问题,我不希望人们能够从我的 GUI 中拖放图像。我已经使用一个小的 java 脚本禁用了文本选择。但我不知道如何禁用图像拖动....我在 body 标记中使用了 onmousedown="return false" 但它禁用了鼠标单击,这会影响我的所有输入字段,因为用户将无法使用鼠标将焦点放在输入对象上......这是我用来禁用鼠标手势的方法。

<html>
<head>
 ....
</head>

<body onmousedown="return false";>
....
</body>
</html>

我不确定 qtwebkit 本身是否有实际的选项/属性来禁用拖动,因为我没有偶然发现与此事相关的任何内容,而且我不想对每个图像单独使用 onmousedown="return false" 代码这将是一场代码屠杀。

编辑:另外,一些图像将用作按钮,禁用鼠标单击将使它们停止运行。

I am trying to create an HTML GUI for an application using Qt's WebKit... so far everything is going smooth with a minor problem, I don't want people to be able to drag and drop images from my GUI. I have disabled text selection using a small java script. But I'm not sure how to disable image dragging.... I have used onmousedown="return false" in the body tag but it disables mouse clicking and this would affect all of my input fields since the user will not be able to get the focus on input objects using the mouse..... Here's the method I used to disable the mouse gestures.

<html>
<head>
 ....
</head>

<body onmousedown="return false";>
....
</body>
</html>

I am not sure if there is an actual option/attribute in qtwebkit itself to disable dragging as I haven't stumbled upon anything relative to this matter plus I don't wanna use the onmousedown="return false" code for each image individually as this would be a code massacre.

Edit: Plus some images will work as buttons and disabling mouse clicks will make them stop functioning.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽袖吟 2024-08-24 06:22:59

尝试

body ondragstart="return false"

Try

body ondragstart="return false"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文