2016년 12월 11일 일요일

Multi-Select in AI2


Abe Getzler

Instead of a whole bunch of check boxes, it’s possible to use two list pickers to maintain lists of included and excluded values.


These two side by side list pickers show their underlying lists in their text areas.
They are wired so that selecting from one side transfers the selected item to the other side.



The list pickers are arranged side by side above a button that resets their contents.


After resetting the list picker lists, we update the list picker Text areas to display the lists vertically.


The AfterPicking blocks for the two list pickers are symmetric.  The selected item is merged into the other list picker’s Elements list, then it is removed from the chosen list picker’s Elements list. Finally, the Text areas of the list pickers are refreshed.

To maintain sort order in the elements lists, we use a function procedure to handle the insertion …


The merge procedure accepts a copy of a list and the value to insert.  It searches from position 1 forward until the end of the list or until the insertion value is no longer greater than the current item. It then inserts the input item at that slot, and returns the updated list.

--

댓글 없음:

댓글 쓰기