Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

TElXTree: Drag Cursor changes unexpectedly

I wrote the following in a delphi NG:
When dragging an item from a tree component, the DragCursor = crDrag
unless the control key is down, in which case the drag cursor used is
crMultDrag. How can I keep it to crDrag regardless of which keys are
down?
Peter Below replied:
"I cannot reproduce the behaviour you are describing with a TTreeview in
Delphi XE2 (on Win7 64). The drag cursor stays what is configured in
the DragCursor property however I try."
How can I keep the same drag cursor no matter which keys are down?
Thanks.
Raymond

Comments

  • 10 Comments sorted by Votes Date Added
  • Hi Raymond,

    I also cannot reproduce issue with crMultiDrag. When I hold Ctrl key down, cursor turns to crDragSingleCopy. 
    Sample project would help to clear out things here. Analyzing code and available properties shows me no way to force drag cursor to one type regardless of key pressed.

    Best regards,
    Victor Bocharov
    bocharov@lmd.de
    LMD Innovative
  • I have attached a demo with full explanation.

    I want crDrag used in each case, even if the Ctrl-key is down.
  • The attachment process doesn't work for me: using Google Chrome.

    Please check the support emails.

    Raymond
  • Did you receive my email with the attached source code demo?

    Raymond
  • Hi, 

    Hmm I checked mail@lmdteam.com and see no letter from you. Can you please resend with сс to bocharov@lmd.de ?

    Thanks
  • I sent it to you again with 'dot' instead of '.' in the zipped filename.

    Have you made progress with this?

    thanks.

    Raymond
  • As mentioned already above:
    Cursor changes are default and an automatic behaviour (CTRL key during drag&drop operations represents Copy operation. This is a standard.)
    If you want to override or switch off default behaviour, simply add this behaviour yourself.

    E.g. fastest way:
    The cursor is determined by the TElXTreeDragObject  type on ElXTree.pas:

      TElXTreeDragObject = class(TDragControlObject)
      public
        procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); override;
        function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;
      public
        destructor Destroy; override;
      end;

    You see there GetDragCursor method. Simply modify this method to return your desired cursor. The whole code inside this method handles ONLY CTRL-key, so you might even simply omit it.


  • How can this be done without modifying the source code?

    Modifying it for each new version of source code is not a solution I want to pursue.

    Raymond
  • >>How can this be done without modifying the source code?<<
    Derive your own descendant and implement any custom behaviour you want. The way shown above was only the simplest way. 
Sign In or Register to comment.