dcl_ListBox_SelItemRange Not calling OnSelChanged

Started by docsaintly, August 06, 2009, 04:58:20 PM

Previous topic - Next topic

docsaintly

In the following code, I make a click event on buttons change the selection of a list box, however they do not appear to call the OnSelChanged event for the list box. The selection get's changed, but the events I want to happen when the selection is changed don't. The events are called when I change the selection manually though. Is this a known bug? Is there a workaround?

Code (autolisp) Select
(defun RangeDisable (/)
(dcl_Control_SetValue chkRange 0)
(dcl_Control_SetEnabled txtRangeStart nil)
(dcl_Control_SetEnabled lblTo nil)
(dcl_Control_SetEnabled txtRangeEnd nil)
)
(defun c:lstBlocks_OnSelChanged (ItemIndex Value / NValue)
(RangeDisable)
(if (setq NValue (last (dcl_ListBox_GetSelectedItems lstBlocks)))
(dcl_DWGPreview_LoadDwg dwgPreview (strcat selectedfolder "\\" NValue))
)
(if (/= (dcl_ListBox_GetSelCount lstBlocks) 0)
(dcl_Control_SetCaption lblFiles (strcat (itoa (dcl_ListBox_GetSelCount lstBlocks)) " selected"))
(dcl_Control_SetCaption lblFiles "No Files Selected")
)
)
(defun c:btnSelectAll_OnClicked (/)
(dcl_ListBox_SelItemRange lstBlocks 0 (dcl_ListBox_GetCount lstBlocks) T)
(dcl_Control_SetCaption lblFiles (strcat (itoa (dcl_ListBox_GetCount lstBlocks)) " selected"))
)
(defun c:btnClearSelect_OnClicked (/)
(dcl_ListBox_SelItemRange lstBlocks 0 (dcl_ListBox_GetCount lstBlocks) F)
(dcl_Control_SetCaption lblFiles "No Files Selected")
)


owenwengerd

OnSelChanged is not called when the selection is changed programmatically. You can call it directly from within your OnClicked handler as (c:lstBlocks_OnSelChanged 0 ""), then your code will work as you expected.

I also noticed that OnSelChanged documentation does not mention the fact that for a multiple selection listbox, ItemIndex is the number of selected items, and Value is always an empty string. I will fix the documentation.
Owen Wengerd (Outside The Box) / ManuSoft