Example #1
0
        public static void InitDragDrop(this IOnDragDropListener listener,
                                        InputElement element)
        {
            element.PointerPressed += async(_, e)
                                      => await DragDrop.DoDragDrop(e, new DataObject(), DragDropEffects.Copy);

            element.AddHandler(DragDrop.DropEvent, Drop);
            element.AddHandler(DragDrop.DragOverEvent, DragOver);

            void DragOver(object?s, DragEventArgs?e)
            {
                if (e?.Data == null)
                {
                    return;
                }
                listener.DragOver(s is InputElement el ? el : element, e);
            }

            void Drop(object?s, DragEventArgs?e)
            {
                if (e?.Data == null)
                {
                    return;
                }
                listener.Drop(s is InputElement el ? el : element, e);
            }
        }