Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-03

Bugs in Delphi DragTo?

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Hans-Peter Diettrich

I suspect at least one error in the Controls.DragTo procedure:

>
     if DragImageList  nil then
     begin
       if (Target = nil) or (csDisplayDragImage in Target.ControlStyle) or
           DragObject.AlwaysShowDragImages then
       begin
         DragImageList.DragCursor := DragCursor;
         if not DragImageList.Dragging then
           DragImageList.BeginDrag(GetDeskTopWindow, Pos.X, Pos.Y)
         else DragImageList.DragMove(Pos.X, Pos.Y);
       end
       else
       begin
         DragImageList.EndDrag; <-------------------------------- 1
         Windows.SetCursor(Screen.Cursors[DragCursor]);
       end;
     end; <------------------------------------------------------ 2
     Windows.SetCursor(Screen.Cursors[DragCursor]);
     if ActiveDrag = dopDock then
[...]
<<

1) EndDrag is called whenever the mouse moves over no valid target (Target=nil). IMO EndDrag should be called only once, when dragging is finished. EndDrag is not appropriate for hiding the drag image temporarily.

2) The duplicate call to SetCursor (and more) suggests to me that the second SetCursor should reside in the Else branch of the outer If, so that it is *not* called after DragImageList.DragMove, just as implemented in the inner If.

Opinions?

Lazarus uses almost the same implementation in TDragPerformer, what IMO should be fixed.

Furthermore I wonder whether it makes sense to show both a drag image *and* an docking frame (in the code below the above snippet, when ActiveDrag=dopDock).

DoDi

Reply by email

Paul Ishenin
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
Lazarus uses almost the same implementation in TDragPerformer, what IMO should be fixed.

What needs to be fixed? Do you have an example where this does not works? DragImageList is not a control, so it is normal that it stops dragging when Target = nil.

Furthermore I wonder whether it makes sense to show both a drag image *and* an docking frame (in the code below the above snippet, when ActiveDrag=dopDock).

DragImageLists is used only for usual drag operations while drag-dock is not a usual drag operation. To represent this operation docking frame is used and there is no need to mix both representations of drag.

Best regards,
Paul Ishenin.

Reply by email