please check my slighly modified and commented script:
Code: Select all
on mouseUp
lock messages
## Speed up things!!!!
lock screen
put 0 into sTempVal
put 16 into tLineHeight
set the textHeight of fld "chkField" to tLineHeight
## This can be done ONCE outside the loop:
set the style of the templateButton to "checkBox"
set the showName of of the templateButton to false
set the width of of the templateButton to 32
set the height of of the templateButton to tLineHeight
repeat with x =1 to 10
## Try to avoid accessing fields in a repeat loop!
## Better collect all data fist and put then into the field!
put "one" & CR after tChkField
## Better use PARENS around concatenated object names!
## Will save your life later, believe me :-D
create button ("chk" & x)
## set the topRight of it to item 1 of the topRight of fld "chkField" + 0 & "," & item 2 of the topRight of fld "chkField" + sTempVal
## I think we cyn omit the + 0 part here ;-)
set the topRight of it to item 1 of the topRight of fld "chkField" & "," & item 2 of the topRight of fld "chkField" + sTempVal
add tLineHeight to sTempVal
end repeat
set the height of fld "chkField" to the textHeightSum of fld "chkField"
set the topRight of fld "chkField" to the topRight of button "chk1"
## OK, this does not work at all this way!
# create group "TickList"
## A field does not have any buttons!
## put the number of buttons of "chkField" into tNosChk
## Although one would think that LC works this way, it doesnt :-/
# repeat with x = 1 to tNosChk
# put button "chk"&x into the group "Ticklist"
# end repeat
# put fld "chkField" into the group "TickList"
## We SELECT all objects we want to group, the GROUP them and name the LAST group:
repeat with x = 1 to 10
set the selected of button ("chk" & x) to TRUE
end repeat
## Don't forget the field:
set the selected of fld "chkField" to TRUE
## NOW:
GROUP
## Give the new group the name you want:
set the name of last grp to "Ticklist"
## Fill field with content:
put tChkField into fld "chkField"
## Good style, to avoid later surprises:
reset the templatefield
## Deselect all:
select emtpy
unlock messages
unlock screen
end mouseUp
Klaus