理想的にはドラッグアンドドロップ(不可能だと思われます)またはボタンを使用して、リストボックス内のリストを並べ替えることができるようにしたいと考えています。上下ボタンのJSLを探しています。
より大きな目標は、ディレクトリ内のすべてのファイルを取得し、ファイル拡張子に基づいてそれらを 2 つのリストに分割することです。 2 つのリストをユーザーに表示し、ペアが一致するようにファイルの順序を変更できるようにします。 [OK] をクリックして 2 つのリスト ボックスからファイル名リストを取得し、それらに対してコードをペアで実行します。リスト ボックス内のリストの並べ替えについてサポートが必要なだけです。
これは、ボタンの非常に迅速なバージョンの 1 つです ( Column Quick Swapper から変更 - Graph Builder で複数の Y 軸と X 軸の列を簡単に変更します)
Names Default To Here(1);
move_items = function({lb_ref, direction}, {Default Local},
all_items = lb_ref << Get Items;
sel_items = lb_ref << Get Selected;
If(direction == "Swap",
item_order = Transform Each({sel_item}, sel_items,
Contains(all_items, sel_item)
);
new_order = all_items;
new_order[item_order] = Reverse(sel_items);
,
start_idx = Contains(all_items, sel_items[1]); // set based first found item
new_list = Filter Each({cur_item}, all_items, !Contains(sel_items, cur_item));
new_idx = If(direction == "Up",
start_idx - 1;
, direction == "Down",
start_idx + 1
,
start_idx
);
new_order = Insert(new_list, sel_items, new_idx);
);
lb_ref << Set Items(new_order);
all_items = lb_ref << Get Items;
For Each({cur_item}, sel_items,
new_idx = Contains(all_items, cur_item);
lb_ref << Set Selected(new_idx, 1, Run Script(0));
);
);
nw = New Window("Example",
H List Box(
lb_ref = List Box(
{"First Item", "Second Item", "Third Item"},
width(200),
max selected(2),
nlines(6)
),
Lineup Box(N Col(1),
btn_up = Button Box("", move_items(lb_ref, "Up"), << Set Icon("ListItemUp"), << Set Tip("Move selection up")),
btn_down = Button Box("", move_items(lb_ref, "Down"), << Set Icon("ListItemDown"), << Set Tip("Move selection down")),
)
)
);
マウスボックスを使用してドラッグアンドドロップを行うこともできると思いますが、私はJMPのボタンの方が好きです(作成がはるかに簡単です)