fix: prevent mouse drag from blocking icon clicks#721
fix: prevent mouse drag from blocking icon clicks#721deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
Fixed an issue where dragging on application icons could block subsequent click events. Added explicit onClicked handler to MouseArea that only triggers root.itemClicked() when not actively dragging. This ensures that drag operations don't interfere with normal click behavior for launching applications. Log: Fixed application launch failure when clicking icons after drag operations Influence: 1. Test clicking application icons to ensure they launch correctly 2. Test dragging icons and verify drag functionality still works 3. Test quick click-drag-release scenarios to ensure no interference 4. Verify both mouse and touch interactions work properly 5. Test edge cases like partial drags and cancellations fix: 修复鼠标拖动导致图标点击失效的问题 修复了在应用程序图标上拖动操作会阻止后续点击事件的问题。为MouseArea添加 了显式的onClicked处理程序,仅在非拖动状态下触发root.itemClicked()。这确 保拖动操作不会干扰正常的点击启动应用程序行为。 Log: 修复拖动操作后点击图标无法启动应用的问题 Influence: 1. 测试点击应用程序图标,确保能正确启动应用 2. 测试拖动图标功能,验证拖动操作仍然有效 3. 测试快速点击-拖动-释放场景,确保没有相互干扰 4. 验证鼠标和触摸交互都能正常工作 5. 测试边缘情况,如部分拖动和取消操作
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts click handling for icon items so that clicks are only processed when no drag is active, fixing a bug where drag operations blocked subsequent click-triggered launches, and removes the previous workaround click handler on the outer control. Sequence diagram for icon click vs drag handlingsequenceDiagram
actor User
participant MouseArea
participant DragHandler as DragHandler_drag
participant Root as IconItemDelegate_root
rect rgb(230,255,230)
Note over User,Root: Simple click (no drag)
User->>MouseArea: press
MouseArea->>DragHandler: startInteraction
DragHandler-->>DragHandler: drag.active = false
User->>MouseArea: release
MouseArea-->>MouseArea: onClicked (drag.active == false)
MouseArea->>Root: itemClicked()
end
rect rgb(255,230,230)
Note over User,Root: Drag operation
User->>MouseArea: press
MouseArea->>DragHandler: startInteraction
DragHandler-->>DragHandler: drag.active = true (movement exceeds threshold)
User->>MouseArea: move (drag)
DragHandler-->>DragHandler: update position
User->>MouseArea: release
MouseArea-->>MouseArea: onClicked (drag.active == true)
MouseArea--xRoot: itemClicked() (blocked by condition)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- By moving
itemClicked()from theControl’sonClickedto the innerMouseArea, keyboard activation (e.g., Enter/Space on a focused item) may no longer trigger clicks; consider keeping a path for non-pointer activation if the delegate is intended to be keyboard-accessible. - Relying solely on
drag.activeto gateitemClicked()may treat very small drags as non-clicks or vice versa depending on howDragHandlerbehaves; consider enforcing a small movement threshold or using the handler’s drag distance to more precisely distinguish drags from clicks.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- By moving `itemClicked()` from the `Control`’s `onClicked` to the inner `MouseArea`, keyboard activation (e.g., Enter/Space on a focused item) may no longer trigger clicks; consider keeping a path for non-pointer activation if the delegate is intended to be keyboard-accessible.
- Relying solely on `drag.active` to gate `itemClicked()` may treat very small drags as non-clicks or vice versa depending on how `DragHandler` behaves; consider enforcing a small movement threshold or using the handler’s drag distance to more precisely distinguish drags from clicks.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review这段代码对 以下是对这段 Diff 的审查意见,分为语法逻辑、代码质量、代码性能和代码安全四个方面: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进建议虽然这段代码已经解决了核心问题,但可以考虑以下微小的优化建议,取决于具体的项目上下文:
总结:这是一次高质量的代码修复。它正确地利用了 Qt Quick 的手势处理机制( |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Fixed an issue where dragging on application icons could block
subsequent click events. Added explicit onClicked handler to MouseArea
that only triggers root.itemClicked() when not actively dragging. This
ensures that drag operations don't interfere with normal click behavior
for launching applications.
Log: Fixed application launch failure when clicking icons after drag
operations
Influence:
fix: 修复鼠标拖动导致图标点击失效的问题
修复了在应用程序图标上拖动操作会阻止后续点击事件的问题。为MouseArea添加
了显式的onClicked处理程序,仅在非拖动状态下触发root.itemClicked()。这确
保拖动操作不会干扰正常的点击启动应用程序行为。
Log: 修复拖动操作后点击图标无法启动应用的问题
Influence:
Summary by Sourcery
Bug Fixes: