2009-04-29 09:47 UTC
Hello,
I have a tree with enabled EditLabel, DragDropAllowDrag and DragDropAllowDrop.
Please imagine 3 items:
A
B
C
I want to drag C to drop between A and B. If A is currently selected and I drag C without selecting C explicitly, I don't know which item was dragged.
To solve this the user has to select the item before he can drag and drop it. But that might cause unexpected results. How can I get the real dragged item? Unfortunately, there is also no HitPointTest for tree controls as it is in ListViews. If so I could use the current MouseCoords to get the dragged item.
(defun c:layer_sc_ltm_tree_OnDragnDropBegin (/)
(princ "\ntree_OnDragnDropBegin\r")
(setq ***ltm_label_drag*** (dcl_Tree_GetSelectedItem layer_sc_ltm_tree))
); c:layer_sc_ltm_tree_OnDragnDropBegin
(defun c:layer_sc_ltm_tree_OnDragnDropFromControl (strProjectName strFormName strControlName uDropPoint /)
(if (and strProjectName (= strProjectName "layer")
strFormName (= strFormName "sc_ltm")
strControlName (or (= strControlName "tree") (= strControlName "lst_prop"))
uDropPoint (= (type uDropPoint) 'STR)
***ltm_label_drag***
(/= ***ltm_label_drag*** uDropPoint))
(princ (strcat "\ntree_OnDragnDropFromControl: " (dcl_Tree_GetItemText layer_sc_ltm_tree ***ltm_label_drag***)
"->" (dcl_Tree_GetItemText layer_sc_ltm_tree uDropPoint) "\r"))
); if
(setq ***ltm_label_drag*** nil)
); c:layer_sc_ltm_tree_OnDragnDropFromControl
Fred
I have a tree with enabled EditLabel, DragDropAllowDrag and DragDropAllowDrop.
Please imagine 3 items:
A
B
C
I want to drag C to drop between A and B. If A is currently selected and I drag C without selecting C explicitly, I don't know which item was dragged.
To solve this the user has to select the item before he can drag and drop it. But that might cause unexpected results. How can I get the real dragged item? Unfortunately, there is also no HitPointTest for tree controls as it is in ListViews. If so I could use the current MouseCoords to get the dragged item.
(defun c:layer_sc_ltm_tree_OnDragnDropBegin (/)
(princ "\ntree_OnDragnDropBegin\r")
(setq ***ltm_label_drag*** (dcl_Tree_GetSelectedItem layer_sc_ltm_tree))
); c:layer_sc_ltm_tree_OnDragnDropBegin
(defun c:layer_sc_ltm_tree_OnDragnDropFromControl (strProjectName strFormName strControlName uDropPoint /)
(if (and strProjectName (= strProjectName "layer")
strFormName (= strFormName "sc_ltm")
strControlName (or (= strControlName "tree") (= strControlName "lst_prop"))
uDropPoint (= (type uDropPoint) 'STR)
***ltm_label_drag***
(/= ***ltm_label_drag*** uDropPoint))
(princ (strcat "\ntree_OnDragnDropFromControl: " (dcl_Tree_GetItemText layer_sc_ltm_tree ***ltm_label_drag***)
"->" (dcl_Tree_GetItemText layer_sc_ltm_tree uDropPoint) "\r"))
); if
(setq ***ltm_label_drag*** nil)
); c:layer_sc_ltm_tree_OnDragnDropFromControl
Fred
