Skip to content

DragDrop: construct DragEventArgs correctly when raising DragLeave event (closes #11774) - #11800

Open
redgreenlight802 wants to merge 2 commits into
dotnet:mainfrom
redgreenlight802:fix-issue-11774
Open

DragDrop: construct DragEventArgs correctly when raising DragLeave event (closes #11774)#11800
redgreenlight802 wants to merge 2 commits into
dotnet:mainfrom
redgreenlight802:fix-issue-11774

Conversation

@redgreenlight802

@redgreenlight802 redgreenlight802 commented Jul 27, 2026

Copy link
Copy Markdown

Fixes #11774

Issue summary

DragEventArgs is constructed with incorrect point when raising DragLeave event.

What Changed

  1. GetCurrentTarget now return client point instead of target-related point.
  2. Add function TranslateClientPoint to translate client point obtained from GetCurrentTarget to specified target point.
  3. Modified OleDragEnter/OleDragOver/OleDrop to adapt to the change of GetCurrentTarget. They will now call TranslateClientPoint before using RaiseDragEvent to raise a drag-drop event.

Why

We need both target-related point and _lastTarget-related point at the same time.
So the minimal change might be separating the client point translate logic and only do that when the element used to raise DragLeave is determined.

Why not just using InputElement.TranslatePoint(targetPoint, target, _lastTarget):
In issue case B, targetPoint is a raw client point, not target-related. The translate logic in TranslateClientPoint is needed.

Microsoft Reviewers: Open in CodeFlow

@redgreenlight802
redgreenlight802 requested a review from a team July 27, 2026 02:44
@redgreenlight802
redgreenlight802 requested a review from a team as a code owner July 27, 2026 02:44
@redgreenlight802

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@dotnet-policy-service dotnet-policy-service Bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DragLeave constructs DragEventArgs with coordinates relative to the new target instead of the event target

1 participant