-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
WPF - Implement UpdateDragCursor #2691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
✅ Build CefSharp 73.0.0-CI2994 completed (commit b4df88f411 by @joaompneves) |
|
✅ Build CefSharp 73.0.0-CI2995 completed (commit a7704e0d26 by @joaompneves) |
amaitland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a list of steps used for testing the different cursor types.
CefSharp.Wpf/ChromiumWebBrowser.cs
Outdated
| { | ||
| //TODO: Someone should implement this | ||
| var dragCursor = DragCursorProvider.GetCursor(operation); | ||
| UiThreadRunSync(() => Mouse.SetCursor(dragCursor)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this is run Sync? If so please add a comment as to the reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an attempt to reduce the flicker, but it still exists.
CefSharp.Wpf/DragCursorProvider.cs
Outdated
| var library = LoadLibrary("ole32.dll"); | ||
| DragCursors = new Dictionary<DragOperationsMask, Cursor>() | ||
| { | ||
| { DragOperationsMask.None, GetCursorFromLib(library, 1) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between this None cursor and Cursors.None? Be better to use the built in one where possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursors.None is an invisible cursor as the None in drag&drop is a forbidden one.
CefSharp.Wpf/DragCursorProvider.cs
Outdated
| DragCursors = new Dictionary<DragOperationsMask, Cursor>() | ||
| { | ||
| { DragOperationsMask.None, GetCursorFromLib(library, 1) }, | ||
| { DragOperationsMask.Move, GetCursorFromLib(library, 2) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Move substantially different from SizeAll? Be better to use the built in cursor where possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it behave if you just map the different types to a built in cursor? Is it something to do with the custom cursor? |
Changed the link with a more self-explanatory example. Just drag the Drag me box over the others. |
Behaves the same way. |
|
✅ Build CefSharp 73.0.0-CI2996 completed (commit d4858fd0ba by @joaompneves) |
|
✅ Build CefSharp 73.0.0-CI2997 completed (commit 9a4541cab8 by @joaompneves) |
|
❌ Build CefSharp 73.0.0-CI2998 failed (commit 5c48f91e4d by @joaompneves) |
|
✅ Build CefSharp 73.0.0-CI2999 completed (commit fdd95111e6 by @joaompneves) |
|
✅ Build CefSharp 73.0.0-CI3000 completed (commit 2254774b5e by @joaompneves) |
|
Solved the flicker problem. The feature is now OK. |
|
✅ Build CefSharp 73.0.0-CI3001 completed (commit 1e51b84361 by @joaompneves) |
|
Turns out the solution is more simple. Just had to store the drag operation result on the update drag cursor and use that in the DragOver event. I have tried this before without success, because the key is to handle the drag over event, otherwise the cursor gets overridden by wpf (default behavior). |
|
✅ Build CefSharp 73.0.0-CI3002 completed (commit cba2b6cdd8 by @joaompneves) |
|
Much cleaner thanks 👍 If all goes well testing wise this will be in the |
|
✅ Build CefSharp 73.0.0-CI3007 completed (commit 18115712c1 by @merceyz) |
|
✅ Build CefSharp 73.0.0-CI3036 completed (commit 69087f0aff by @amaitland) |
|
Formatting fixes for the html file in ea843f3
|

Implemented the UpdateDragCursor method of the WPF webview.
Tested with: https://jsfiddle.net/tw5f801j/
The drag&drop cursors are retrieved from Windows lib (ole32) and displayed when appropriate.
The implementation still has a minor problem: the cursor flickers, which is more noticeable when the cursor changes to forbidden. I don't know why this happens. If anyone can shed light, that would be much appreciated.