TControl.SetDragCursor doesn't update cursor immediately
Original Reporter info from Mantis: cordylus
-
Reporter name:
Original Reporter info from Mantis: cordylus
- Reporter name:
Description:
You can reproduce the problem easily by changing DragCursor on Shift KeyDown/KeyUp during dragging, the cursor will not be updated on the screen until the mouse moves.
Current code in LCL is just:
procedure TControl.SetDragCursor(const AValue: TCursor);
begin
if FDragCursor=AValue then exit;
FDragCursor:=AValue;
end;
First, I thought it should be fixed by analogy with TDragImageList.SetDragCursor:
procedure TControl.SetDragCursor(const AValue: TCursor);
begin
if FDragCursor=AValue then exit;
FDragCursor:=AValue;
if DragManager.Dragging(Self) then
WidgetSet.SetCursor(Screen.Cursors[DragCursor]);
end;
And it seemed to work until the cursor was set when it was in a NoDrop zone, then the cursor has changed anyway, although it shouldn't. (Wouldn't this be a bug in TDragImageList?)
Then, considering that pressing Control updates the cursor, I found TDragManagerDefault.KeyDown and took the approach from there:
procedure TControl.SetDragCursor(const AValue: TCursor);
begin
if FDragCursor=AValue then exit;
FDragCursor:=AValue;
if DragManager.Dragging(Self) then
DragManager.DragMove(Mouse.CursorPos);
end;
This works good, yet I'm not sure if it's OK to send a message (SendCmDragMsg in TDragPerformer.DragMove) when the cursor changes.
Alternatively, I suggest caching somewhere the latest result of SendCmDragMsg that is used as the "Accepted" parameter of TDragControlObject.GetDragCursor which decides whether it'll be the current drag cursor or crNoDrop.
Mantis conversion info:
- Mantis ID: 31943
- OS: Windows
- Version: 1.6.4
- Monitored by: » @martin_frb (Martin Friebe)