Exemple #1
0
        internal bool HandleDragOver(CGPoint viewPoint)
        {
            if (activeGlyphDropHandler == null)
            {
                return(false);                // not dragging
            }

            if (!dragOccurred)
            {
                // if the mouse moved position is less than the system settings for drag start, don't start the
                // drag operation
                Vector dragDelta = new Vector(clickLocation.X - viewPoint.X, clickLocation.Y - viewPoint.Y);
                if (Math.Abs(dragDelta.X) < SystemParameters.MinimumHorizontalDragDistance && Math.Abs(dragDelta.Y) < SystemParameters.MinimumVerticalDragDistance)
                {
                    return(false);
                }

                // Now that the mouse has moved, this is an actual drag.
                dragOccurred = true;
            }

            var(line, column) = GetLineNumberAndColumn(viewPoint);

            // If this line isn't in the data (surface) buffer, we can't use it
            if (line < 0)
            {
                return(false);
            }

            // Query if we can drop here and set mouse cursor appropriately.
            if (activeGlyphDropHandler.CanDrop(line, column))
            {
                // We can drop here.  Use "hand" cursor.
                //TODO:MAC
                //Mouse.OverrideCursor = Cursors.Hand;
            }
            else
            {
                // Can't drop here; change mouse cursor.
                //TODO:MAC
                //Mouse.OverrideCursor = Cursors.No;
            }

            // if the view does not have any focus, grab it
            if (!textViewHost.TextView.HasAggregateFocus)
            {
                var viewToFocus = textViewHost.TextView.VisualElement;
                viewToFocus.Window.MakeFirstResponder(viewToFocus);
            }

            // Position the drag/drop caret and ensure it's visible.
            ITextViewLine textViewLine = GetTextViewLine(viewPoint.Y);

            viewPrimitives.Caret.AdvancedCaret.MoveTo(textViewLine, viewPoint.X);

            this.EnsureCaretVisibleWithPadding();

            return(true);
        }
Exemple #2
0
        internal bool HandleDragEnd(CGPoint viewPoint)
        {
            // Clean up our dragging state.
            //glyphMargin.VisualElement.ReleaseMouseCapture();
            //Mouse.OverrideCursor = null;

            IActiveGlyphDropHandler glyphDropHandler = activeGlyphDropHandler;

            activeGlyphDropHandler = null;

            // Did we actually do a drag?
            if (!dragOccurred)
            {
                return(false);
            }

            dragOccurred = false;

            if (glyphDropHandler != null)
            {
                var(line, column) = GetLineNumberAndColumn(viewPoint);

                // If this line isn't in the data (surface) buffer, we can't use it
                if (line < 0)
                {
                    return(false);
                }

                // Query if we can drop here.
                if (glyphDropHandler.CanDrop(line, column))
                {
                    glyphDropHandler.DropAtLocation(line, column);
                }
            }

            // Even if we couldn't drop here, we return true to ensure that we don't handle this as a normal click.
            return(true);
        }