AppleScript 列表对话框中的键盘快捷键 [英] Keyboard shortcuts in an AppleScript list dialog

查看:40
本文介绍了AppleScript 列表对话框中的键盘快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,可以为 AppleScript 中列表对话框中的项目分配键盘快捷键.

I am looking for a way to assign keyboard shortcuts to the items in a list dialog in AppleScript.

我正在使用以下内容来显示一长串文件夹名称,并且正在寻找一种从列表中选择项目的简单方法.

I am using the following to display a long list of folder names and am looking for an easy way to select an item from the list.

set selectedFolderName to {choose from list folderList}

当前列表显示如下:

Office
Personal
Projects
... 
Vendors

而且我必须使用光标键或鼠标在列表中向下导航以选择一个项目.我希望能够显示:

and I have to navigate down the list with the cursor keys or mouse to select an item. I would like to be able to show either :

a) Office
b) Personal
c) Projects
... 
m) Vendors

或:

Office
Personal
pRojects
... 
Vendors

然后我可以按 C 键(第一个示例)或 R 键(第二个示例)来选择项目".

Then I could press the C key (first example) or R key (second example) to select 'Projects'.

我研究了 AppleScript 文档,例如它,并进行了广泛的搜索,但没有找到实现此目的的方法.

I studied the AppleScript documentation, such as it is, and searched far and wide, but have not been able to spot a way to accomplish this.

推荐答案

我不完全确定这是否是您想要的,但我使用下面的构造,以便我可以按a",选择第一个项,b"选择第二项,依此类推.

I'm not totally sure if this is what you want, but I use the construct below, so that I can press "a", to select the first item, "b" to select the second item, and so on.

set litems to {"apples", "pears", "banana", "oranges", "plums", "grapes"}

set deli to "." & space & space
repeat with i from 1 to (count litems)
    set item i of litems to character id (i + 96) & deli & item i of litems
end repeat
log litems
set theRes to choose from list litems
(*a.  apples, b.  pears, c.  banana, d.  oranges, e.  plums, f.  grapes*)
set origItem to text 5 thru -1 of item 1 of theRes
log origItem
—> plums    

这篇关于AppleScript 列表对话框中的键盘快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆