OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: krunch on November 01, 2012, 05:42:19 PM

Title: Problem with a ListBox + SetItemData
Post by: krunch on November 01, 2012, 05:42:19 PM
Hi

I have a ListBox with wich I'd want to use ItemData, but SetItemData doesn't seem to record my list ..
Example :

Code (autolisp) Select
(defun c:Project_Form_OnInitialize ()
    (dcl_Control_SetList Project_Form_lst0 '("a" "b" "c")
    (dcl_Control_SetItemData Project_Form_lst0 '(0 1 2))

    (print (dcl_Control_GetItemData Project_Form_lst0))
)

> (0 0 0)

Did I miss something ?
Title: Re: Problem with a ListBox + SetItemData
Post by: owenwengerd on November 01, 2012, 07:23:54 PM
The code in your post is using the item data functions incorrectly and results in argument exceptions. If you don't see the exception message dialogs, use (dcl_SuppressMessages NIL) (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Function/SuppressMessages.htm) to turn them back on. Please take a look at the function syntax of (dcl_ListBox_SetItemData) (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/ListBox/SetItemData.htm) and post back if you have additional questions.
Title: Re: Problem with a ListBox + SetItemData
Post by: krunch on November 02, 2012, 03:38:44 AM
Ok thanks Owen

I had looked at the 'ItemData' property in the help ..
QuoteSet Function   (dcl_Control_SetItemData Project_Form_lst0 NewValue [as List of Longs])
Does it means that we can't apply it to List Box (only combo boxes) ?

The error message is not triggered, even with (dcl_SuppressMessages NIL)
Title: Re: Problem with a ListBox + SetItemData
Post by: owenwengerd on November 02, 2012, 09:21:27 AM
Sorry, I misread your original code and didn't notice that you were setting the property vs. calling the SetItemData method. It is indeed a bug, and I have fixed it now for the next build. In the meantime, you can work around the bug by getting and setting individual data for items using the GetItemData and SetItemData methods.
Title: Re: Problem with a ListBox + SetItemData
Post by: krunch on November 08, 2012, 06:48:52 AM
Ok

Just another remark : when you drag and drop items from a listbox to another the ItemData doesn't seem to follow (?)
Title: Re: Problem with a ListBox + SetItemData
Post by: owenwengerd on November 08, 2012, 08:45:36 PM
The default drag/drop handler is very basic and only copies the item text to the clipboard as plain text. To include the item data, it would either need to be encoded into the item text, or the list control would need to use a custom clipboard format for storing both item text and item data together. Modifying the item text is problematic because the encoded item data would then get dropped into places where it wouldn't be expected. The custom clipboard format would probably work, but it's not easy to implement.

I'll agree that the current behavior is a bit unintuitive when dragging from listbox to listbox, but that in itself is probably not enough reason to invest the effort in implementing a new clipboard format plus the code to handle the new format during drag and drop operations. In any case, you can create a custom drag/drop handler that transfers the item data for your own listbox control, so with a little work you should be able to work around the problem locally.
Title: Re: Problem with a ListBox + SetItemData
Post by: krunch on November 09, 2012, 06:56:37 AM
ok, this structure is already enough to do many things and it's true that we can transfer the item data with dragndrop event .. Thanks