Skip to content

Conversation

@joaompneves
Copy link
Contributor

@joaompneves joaompneves commented Mar 15, 2019

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.

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

Copy link
Member

@amaitland amaitland left a 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.

{
//TODO: Someone should implement this
var dragCursor = DragCursorProvider.GetCursor(operation);
UiThreadRunSync(() => Mouse.SetCursor(dragCursor));
Copy link
Member

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.

Copy link
Contributor Author

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.

var library = LoadLibrary("ole32.dll");
DragCursors = new Dictionary<DragOperationsMask, Cursor>()
{
{ DragOperationsMask.None, GetCursorFromLib(library, 1) },
Copy link
Member

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

https://docs.microsoft.com/en-us/dotnet/api/system.windows.input.cursors.none?view=netframework-4.7.2

Copy link
Contributor Author

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.

DragCursors = new Dictionary<DragOperationsMask, Cursor>()
{
{ DragOperationsMask.None, GetCursorFromLib(library, 1) },
{ DragOperationsMask.Move, GetCursorFromLib(library, 2) },
Copy link
Member

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.

https://docs.microsoft.com/en-us/dotnet/api/system.windows.input.cursors.sizeall?view=netframework-4.7.2#System_Windows_Input_Cursors_SizeAll

Copy link
Contributor Author

@joaompneves joaompneves Mar 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drag&drop cursors don't exist in the built-in collection.

These are the ones we get from ole32:
Cursors

@amaitland
Copy link
Member

The implementation still has a minor problem: the cursor flickers

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?

@amaitland amaitland changed the title Drag drop cursors WPF - Implement UpdateDragCursor Mar 16, 2019
@joaompneves
Copy link
Contributor Author

Please provide a list of steps used for testing the different cursor types.

Changed the link with a more self-explanatory example. Just drag the Drag me box over the others.

@joaompneves
Copy link
Contributor Author

The implementation still has a minor problem: the cursor flickers

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?

Behaves the same way.

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@joaompneves
Copy link
Contributor Author

Solved the flicker problem. The feature is now OK.

@AppVeyorBot
Copy link

@joaompneves
Copy link
Contributor Author

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).

@AppVeyorBot
Copy link

@amaitland amaitland added wpf WPF Implementation and removed not-ready-for-merge labels Mar 19, 2019
@amaitland amaitland added this to the 73.0.0 milestone Mar 19, 2019
@amaitland
Copy link
Member

Much cleaner thanks 👍 If all goes well testing wise this will be in the 73 release.

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@amaitland amaitland merged commit 6692749 into cefsharp:master Apr 5, 2019
amaitland added a commit that referenced this pull request Apr 5, 2019
Follow up to #2691
@amaitland
Copy link
Member

Formatting fixes for the html file in ea843f3

& needs to be encoded as &amp; for xml doc also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wpf WPF Implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants