順序の変更が可能な項目選択(指定)ダイアログ表示AppleScriptです。
項目を行単位でドラッグ&ドロップして順番を変更できるようになっています。この機能を自前で作ろうとすると、筆舌に尽くし難いほど大変なのでMyriad Tables Libを利用して作ってみました。
Myriad Tables Libはたいへんに多機能なライブラリですが、あえて限定された機能だけを利用してみるというのもアリでしょう。
なにげに、仕事で実際に納品するプログラムによく使っています、Myriad Tables Lib。
AppleScript名:順序変更可能な項目選択ダイアログ.scpt |
— – Created by: Takaaki Naganoya – Created on: 2019/04/28 — – Copyright © 2019 Piyomaru Software, All Rights Reserved — use AppleScript version "2.4" use framework "Foundation" use framework "AppKit" use scripting additions use script "Myriad Tables Lib" version "1.0.9" –https://www.macosxautomation.com/applescript/apps/Script_Libs.html set aTitle to "順番を指定してください" set aPrompt to "各行はドラッグ&ドロップで順序を変更できます" set origData to {"iMac 5K", "MacBook Pro", "Mac mini", "MacBook Air", "MacBook", "Mac Pro", "iMac Pro"} set selRowList to dispDroppableTableViewDialog(aTitle, aPrompt, origData) of me –>{"Mac mini", "MacBook Air", "MacBook", "Mac Pro", "MacBook Pro", "iMac 5K", "iMac Pro"} –順序変更可能なダイアログを表示 on dispDroppableTableViewDialog(aTitle, aPrompt, origData) set someData to make1DListTo2D(origData) of me set myTable to make new table with data someData with title aTitle with prompt aPrompt initially selected rows {1} with multiple selections allowed set theAccessoryView to current application’s NSView’s alloc()’s initWithFrame:(current application’s NSMakeRect(0, 0, 400, 0)) modify table myTable accessory view theAccessoryView with row dragging set theResult to (display table myTable) set selList to values returned of theResult set sel2List to FlattenList(selList) of me return sel2List end dispDroppableTableViewDialog –1D Listを2D Listに変換 on make1DListTo2D(aList as list) set outList to {} repeat with i in aList set j to contents of i set the end of outList to {j} end repeat return outList end make1DListTo2D on FlattenList(aList) set oldDelims to AppleScript’s text item delimiters set AppleScript’s text item delimiters to {"????"} set aString to aList as text set aList to text items of aString set AppleScript’s text item delimiters to oldDelims return aList end FlattenList |
More from my site
(Visited 154 times, 1 visits today)