I have a GUI with two list boxes. I want to maintain the list box content exclusive of each other. The list box contents are not unique. I want to move selected items to other box and remove from the source. I have implemented the move call back as follows. Since I have used member function, not able to retain duplicate values. Is there any better way of doing?
;;scrField and dstField are the list box field
procedure(moveBin(scrField dstField)let((scrList dstList) scrList = hiGetListBoxValue(scrField) dstList = dstField->choices foreach(ele scrList dstList = cons(ele dstList) ) dstField->choices = dstList scrList = setof(x scrField->choices !member(x dstList)) scrField->choices = scrList))
I'm not sure I quite get what you're asking (I can guess, but I might be guessing wrong). Perhaps a picture of what the form looks like, what it does now and what you're expecting it to do?
Here is a picture of my GUI. I want to move selected elements back and forth from pin list listBoxField to selection bin listBoxField. The above procedure is the callback implementation of move buttons. I swap scrField and dstField to move left to right and vice versa. Things works but when there are duplicate entries in the listBox, the above callback is not able to handle and maintain only unique ones since I have used member function.
Overnight I got another idea by maintaining the list box entries unique by appending with pin's bBox which works fine. But still wondering how to do if entries are not unique.
How about something like this?
let((scrList dstList usedCount)
scrList = hiGetListBoxValue(scrField)
usedCount = makeTable('usedCount 0)
dstList = dstField->choices
dstList = cons(ele dstList)
usedCount[ele] = usedCount[ele] + 1;
dstField->choices = dstList
scrList = setof(x scrField->choices
usedCount[x] = usedCount[x] - 1
scrField->choices = scrList
Thanks for the solution. I have never thought of using a if-else block inside setoff. Something new I learnt.
On a related topic, I see some trouble in doing multiple selection by dragging or holding shift in a list box when the entries are duplicate. The selection does not happen continuous, there are few unselected items in between. Is it a known issue? I am using virtuoso version ICADV12.3-64b 12/04/2018 18:23.
Yes, I see that slightly odd behaviour too. I thought something felt odd yesterday when I was trying this out, but I didn't play with it long enough to notice what wasn't right. I suggest you contact customer support with an example to get this fixed...