You can easily set a table to the content of a list, but how do you set a list to the contents of a table?
I have a simple one column table that is editable. I simply want to get the edited list after the user is done editing the table, as a normal list of strings. Instead, what I get is a list with items like this: {|table column 1|:“live”}
Can anyone tell me what I’m doing wrong? This is the first time I’ve tried to use tables, and it’s confusing to me.
This is what I have tried so far:
property reswords : {"live", "mix", "remix", "re-mix", "Unknown Pleasures", "", "", "", "", "", "", "", "", "", "", ""}
property restable : {}
on clicked
if name of theObject is "resedit" then
-- button opens a panel with a one column table
set restable to reswords
set content of table view "restable" of scroll view "resscroll" of window "respanel" to restable
display panel window "respanel" attached to window "main"
else if name of theObject is "resdone" then
-- button closes the panel with the table, passes it to panel ended handler
close panel (window of theObject) with result 1
end if
end clicked
on panel ended thePanel with result theResult
if theResult is 1 then
set dataSource to data source of table view "restable" of scroll view "resscroll" of window "respanel"
set resrows to every data row of dataSource
set reswords to {}
repeat with arow in resrows
copy (content of arow) to the end of reswords
end repeat
end panel ended
Result: reswords:
{{|table column 1|:"live"}, {|table column 1|:"mix"}, {|table column 1|:"remix"}, {|table column 1|:"re-mix"}, {|table column 1|:"Unknown Pleasures"}, {|table column 1|:""}, {|table column 1|:""}, {|table column 1|:""}, {|table column 1|:"ret"}, {|table column 1|:""}, {|table column 1|:""}, {|table column 1|:""}, {|table column 1|:""}, {|table column 1|:""}, {|table column 1|:""}, {|table column 1|:""}}
Alternate attempt:
on panel ended thePanel with result theResult
if theResult is 1 then
set reswords to contents of table view "restable" of scroll view "resscroll" of window "respanel"
end if
end panel ended
Result: reswords = same as above
Alternate attempt:
on panel ended thePanel with result theResult
if theResult is 1 then
tell table view "restable" of scroll view "resscroll" of window "respanel" to update
set reswords to restable
end panel ended
Result: reswords = the original values of the restable, even if you edit the table (ie, i thought somehow the list restable is supposed to be automatically linked to the table view as long as the name of the variable (restable) is the same as the name of the table view (restable) in IB.
Thank you!