Skip to content
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

[Documentation] Pointer Capture and Other Mouse/Touch Events #35

Open
keldor314 opened this issue Dec 10, 2020 · 4 comments
Open

[Documentation] Pointer Capture and Other Mouse/Touch Events #35

keldor314 opened this issue Dec 10, 2020 · 4 comments

Comments

@keldor314
Copy link

keldor314 commented Dec 10, 2020

There's basically no documentation about mouse and touch events, and there's a decent bit of nuance that's not necessarily obvious.

One big example is capture. When is capture gained? When is it lost? What happens if the control which has captured the pointer has is moved/deactived/hidden while the mousebutton is still down? I don't want to deal with missing button release events.

Another use case is finding out what control is beneath the pointer when the button is released. In my case, I want a Visual Studio like docking control, so I'm handing over a control to a different part of the visual and logical trees on mouse release, provided the mouse is over a valid target.

The problem is that DragDrop is severely inadequate for this sort of use. I can of course serialize a reference into a string and back again, and use reflection to validate types, but this is a horrible kludge, and I don't particularly want my app leaking object references or other odd side effects if the user happens to drag something meant for internal use off to another program or over a textbox or something. However, to my knowledge, there just isn't a better way to do it.

@danwalmsley
Copy link
Member

FYI the most complete implementation of any docking system in avalonia is...
https://github.com/wieslawsoltes/Dock

you may be able to use that, or figure out some of these things from the code there.

@kekekeks
Copy link
Member

The problem is that DragDrop is severely inadequate for this sort of use

With in-process drag-n-drop you should get exactly the same IDataObject that you've passed to DoDragDrop, so no serialization is needed. If it's not the case, please, file an issue.

@keldor314
Copy link
Author

keldor314 commented Dec 12, 2020

Ah, I see. I was confused because of the presence of the DataFormats enumeration made me believe that DataFormats.Text and DataFormats.FileNames were the only valid data types.

I guess the next question is what happens when you try to pass an arbitrary object across process boundaries. It seems like there's a lot of potential for bad things to happen here. Should there be an way to restrict drop targets to those existing in the current assembly? What about using ISerializable or System.IO.Stream?

@kekekeks
Copy link
Member

what happens when you try to pass an arbitrary object across process boundaries.

Mostly nothing. When DnD happens between processes we enumerate data formats supported by your data object and convert those to platform-specific APIs. So if your data object doesn't contain anything the target app won't see any compatible formats and refuse the DnD operation. For custom formats we currently only handle string and byte[] representations, I think.

@maxkatz6 maxkatz6 transferred this issue from AvaloniaUI/Avalonia May 25, 2022
@maxkatz6 maxkatz6 transferred this issue from another repository Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants