question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Drag-Drop improvements

See original GitHub issue

Is your feature request related to a problem? Please describe.

A couple issues I’ve come across with drag-drop (in-app, not to/from external process):

1 - IMO, the drag-drop events really need to sit in one of the base classes to all controls like it is in WPF/UWP (in UIElement). There are some cases where being able to do some logic before or after one of the drag events is raised is super helpful (thus needing a protected virtual method) as you can’t rely on AddHandler() to do, particularly in the latter case.

2 - If a control that acts as a drag source contains a ToolTip, the ToolTip needs to be hidden as part of drag drop activating, which follows WPF. Otherwise, the ToolTip will hide, but the drag/drop icon flickers as the pointer moves.

3 - DragLeave event should have DragEventArgs instead of just RoutedEventArgs - so pointer information can be retrieved

4 - One of the things I also was trying to implement, similar to UWP dragging, is a popup with a preview of the item being dragged - except it seems the popup doesn’t respond to the changes in position during drag drop. popup.Host.ConfigurePosition() is called but the popup remains in one place. It also seems that all of the InputManager methods (process, preprocess, postprocess) don’t do anything during drag drop and return (-1,-1) only once upon querying RawPointerEventArgs.Position, which makes this task impossible to achieve in any way that I can see. I’ve tested with WPF and this is possible

5 Current implementation preprocess events in global static IInputManager to simulate dnd

Describe the solution you’d like A clear and concise description of what you want to happen.

Describe alternatives you’ve considered A clear and concise description of any alternative solutions or features you’ve considered.

Additional context Add any other context or screenshots about the feature request here.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:9
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
amwxcommented, Nov 17, 2022

I’ve done some more investigating into this, particularly (4). The InputManager returning (-1,-1) is only occuring because the wrong RawEvent is being queried. If you use RawDragEvent instead of RawPointerEventArgs you can still get input messages during drag drop. The (-1,-1) is from a random WM_MOUSELEAVE event that occurs shortly after starting DragDrop However, this will only work while dragging inside the HWND. In WPF you can get this to work by handling the GiveFeedback event, originating from IOleDropSource.OleGiveFeedback but to get the mouse position outside the window you need GetCursorPos() which obviously doesn’t work for touch/pen. Though I have no idea if the other platforms have something similar to OleGiveFeedback/is a way to mock it for parity. So (4) may not be entirely possible in a cross-platform, modern framework like Avalonia. Not to mention, I still cannot figure out why the popup refuses to move when in drag-drop (even if force-repositioned after RawDragEvent)

UWP does have CoreDragOperation.SetDragUIContentFromSoftwareBitmap, so there might be an option to pass in a bitmap to be set as the mouse cursor that gives the drag preview. Still requires the GiveFeedback event, has the downside of removing the default drag feedback cursors, and probably isn’t cross-platform.

Also an aside, RawDragEvent probably should be renamed to RawDragEventArgs to be consistent with the other raw event args.

1reaction
Hanprogramercommented, Mar 22, 2023

I think Avalonia needs a way to allow/not allow drag and drop from code. This would be better explained in a scenario: You’re trying to implement drag and drop, then there’s a target to drop files, but it only accepts certain file formats, for example just PNGs, we need a way to handle this properly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improvements to our drag and drop system
We're releasing improvements to our drag-and-drop system to make it easier than ever to build UIs within Retool. With our new preview ...
Read more >
Drag and drop mode: UI improvements
Here are some small improvements to the UI: Added more contrast for the paragraph type labels; Added the ghost item again since it...
Read more >
Drag drop usability improvements
I attached a real quick and dirty mock up of possible improvements to make to the new drag and drop system that was...
Read more >
Drag Drop ListBox Dragging Behaviour Improvements
Hi Telerik Team,While doing the drag and drop functionality, to locate the place of the card while dropping we are having a ORANGE...
Read more >
DragDrop Class (System.Windows)
Drag-and-drop operations typically involve two parties: a drag source from which the dragged data originates and a drop target which receives the dropped...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found