You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with the drag/drop library on a Surface Pro, trying to use a Stylus. The Stylus events get correctly translated into Mouse Events, and are handled by the library appropriately.
However, in my viewmodel that handles the IDropTarget, I attempt to pop open a dialog, with a basic Window.ShowDialog() call. When I use a mouse, this works fine. But when I use a stylus (or touch), the newly opened dialog is unable to respond to stylus (or touch) events.
The idea being that for stylus/touch events, the handler needs to return first before other UI-blocking events are invoked. The way I solved this in my own pull of the code is to make the view model code invoke asynchronously. I made the following change in DragDrop.cs:
privatestaticvoidDropTarget_PreviewDrop(objectsender,DragEventArgse){vardropInfo=new DropInfo(sender, e, m_DragInfo);vardropHandler= TryGetDropHandler(dropInfo, sender as UIElement);vardragHandler= TryGetDragHandler(m_DragInfo, sender as UIElement);DragAdorner=null;EffectAdorner=null;DropTargetAdorner=null;
dropHandler.DragOver(dropInfo);
dropHandler.Drop(dropInfo);
dragHandler.Dropped(dropInfo);
Mouse.OverrideCursor =null;
e.Handled =!dropInfo.NotHandled;}
To
privatestaticasyncvoidDropTarget_PreviewDrop(objectsender,DragEventArgse){vardropInfo=new DropInfo(sender, e, m_DragInfo);vardropHandler= TryGetDropHandler(dropInfo, sender as UIElement);vardragHandler= TryGetDragHandler(m_DragInfo, sender as UIElement);DragAdorner=null;EffectAdorner=null;DropTargetAdorner=null;
Mouse.OverrideCursor =null;await Dispatcher.CurrentDispatcher.InvokeAsync(()=>{ dropHandler.DragOver(dropInfo); dropHandler.Drop(dropInfo); dragHandler.Dropped(dropInfo);});
e.Handled =!dropInfo.NotHandled;}
This appears to allow the desired behavior, though I am not currently testing whether setting e.Handled after an await call works as expected. It does make use of async/await, so it may not be viable for the overall solution, but maybe something similar can be incorporated in the future.
The text was updated successfully, but these errors were encountered:
I'm working with the drag/drop library on a Surface Pro, trying to use a Stylus. The Stylus events get correctly translated into Mouse Events, and are handled by the library appropriately.
However, in my viewmodel that handles the IDropTarget, I attempt to pop open a dialog, with a basic Window.ShowDialog() call. When I use a mouse, this works fine. But when I use a stylus (or touch), the newly opened dialog is unable to respond to stylus (or touch) events.
I believe this is the same issue noted here: http://stackoverflow.com/questions/21178504/touch-events-not-working-after-dodragdrop
And I think the solution is the same as the one here: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/d9e4335b-beaa-4ecf-abd6-a900af8a9e41/show-a-dialog-inside-touchup-event?forum=wpf
The idea being that for stylus/touch events, the handler needs to return first before other UI-blocking events are invoked. The way I solved this in my own pull of the code is to make the view model code invoke asynchronously. I made the following change in DragDrop.cs:
To
This appears to allow the desired behavior, though I am not currently testing whether setting e.Handled after an await call works as expected. It does make use of async/await, so it may not be viable for the overall solution, but maybe something similar can be incorporated in the future.
The text was updated successfully, but these errors were encountered: