Hello,
I want to change the order within a listview, but not using automatic drag&drop functionality but by customized OnDragBegin and OnDrop events because I change XRecordData at the same time.
I move the items by deleting and inserting the items. But in the end of OnDrop event the inserted items shall be selected. And although I select them another item seems to be selected instead (afterwards).
Because OnClicked will be fired after OnDrop event has been finished, I still cannot select the newly inserted (moved) items. Do I call the select function afterwards on the commandline it works fine.
(defun c:layer_sc_ltm_lst_prop_OnClicked (intRow intColumn / oGroup isGroup)
(princ "\nlst_prop_OnClicked\r")
(if ***ltm_list_sel*** (LTM_MANAGER_SELECTITEMS ***ltm_list_sel***))
(setq ***ltm_list_sel*** nil)
(setq isGroup (and (setq oGroup (LTM_MANAGER_ITEMS))
(= (length oGroup) 1)
(setq oGroup (cdar oGroup))
(LTM_OBJ_ISXREC oGroup)))
(dcl_Control_SetVisible layer_sc_ltm_pb_lg_edit isGroup)
(dcl_Control_SetVisible layer_sc_ltm_pb_lg_del isGroup)
); c:layer_sc_ltm_lst_prop_OnClicked
(defun c:layer_sc_ltm_lst_prop_OnDragnDropBegin (/)
(princ "\nlst_prop_OnDragnDropBegin\r")
(setq ***ltm_list_drag*** (LTM_MANAGER_ITEMS))
(dcl_Control_SetDragnDropAllowDrop layer_sc_ltm_lst_prop T) ;; it was set nil when an item of the tree is going to be dragged
); c:layer_sc_ltm_lst_prop_OnDragnDropBegin
(defun c:layer_sc_ltm_lst_prop_OnDragnDropFromControl (strProjectName strFormName strControlName uDropPoint / lstObj lstItem oItem)
(princ "\nlst_prop_OnDragnDropFromControl\r")
(if (and (setq lstObj ***ltm_list_drag***)
(setq lstItem (dcl_ListView_HitPointTest layer_sc_ltm_lst_prop (car uDropPoint) (cadr uDropPoint)))
(setq oItem (LTM_MANAGER_ITEMID (car lstItem)))
(not (member oItem (mapcar 'cdr lstObj))))
(progn
(princ (strcat "\rlst_prop_OnDragnDropFromControl: " (itoa (length lstObj)) " Objekte\r"))
(LTM_MANAGER_DELETEITEMS (mapcar 'car lstObj))
;; a list of inserted items as integer is given back
(if (setq ***ltm_list_sel*** (LTM_MANAGER_INSERTITEMS (mapcar 'cdr lstObj) (LTM_MANAGER_GETITEMPOS oItem)))
(LTM_MANAGER_SELECTITEMS ***ltm_list_sel***)
); if
); progn
); if
(setq ***ltm_list_drag*** nil)
); c:layer_sc_ltm_lst_prop_OnDragnDropFromControl
Is there a chance to control that?
Fred
Hello,
I removed a small bug of LTM_MANAGER_INSERTITEMS and it works now if I select items from the OnClicked event that is automatically called after OnDrop event.
But shouldn't it also work if I change the selection within the OnDrop event?
Fred
I've made a change to the code so that SetCurSel works inside OnDragDropFromControl. I also noticed that the automatic drag/drop handling is not yet completed for the list view control; I think I was waiting to complete that until I had it working without any problems in the list control.