如何创建按钮,使用脚本数组? [英] How do I create an array of buttons with a script?

查看:183
本文介绍了如何创建按钮,使用脚本数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建按钮的阵列的脚本。这包括设置的大小和位置,并分配一个mouseUp事件处理程序去它们。

I'd like to create an array of buttons with a script. This includes setting the size and position and assigning a mouseUp hander go them.

鼠标松开处理器应该是

on mouseUp
    go to card "aName"
end mouseUp

名称的列表是一个文本变量tCardNames。每一行都有一个卡名称。

The list of names is in a text variable tCardNames. Each line has a card name.

推荐答案

下面是一个稍微不同的方法。每个在重复的形式是长列表比的更有效的使用重复,但在这种情况下,有可能会是没有AP preciable差异。

Here's a slightly different approach. The repeat for each form is more efficient for long lists than repeat with, but in this situation there would likely be no appreciable difference.

on createButtons
  repeat for each line tBtnName in tCardNames
    createNamedButton tBtnName
  end repeat
end createButtons

on createNamedButton pName
  create button pName
  set the script of btn pName to "on mouseUp" & cr & \
    "go cd " & quote & pName & quote & cr & \
    "end mouseUp"
  put the number of btn pName into tNum
  set the top of btn pName to (10 * 30 * (tNum - 1))
end createNamedButton

这篇关于如何创建按钮,使用脚本数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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