Thursday, October 17, 2019

#1 2019-09-29 01:08:03 pm

AoRaToS
Member
From:: Greece
Registered: 2019-09-01
Posts: 8
Website

Updating multiple TextView objects

Hello all,

Is there a way of keeping a reference or list of properties (linked to button or TextView objects) or a way of doing the below?
For example,

I have a window with 3 different TextView objects connected to the below properties, I can update their text using:

property textViewItem_1 : missing value
property textViewItem_2 : missing value
property textViewItem_3 : missing value

textViewItem_1's setStringValue : "test1"
textViewItem_2's setStringValue : "test2"
textViewItem_3's setStringValue : "test3"

Is there a way I can set their value in a loop? Something like:

repeat with a from 1 to 3
textViewItem_(a)'s setStringValue : "test" & a
end repeat

Is this possible?

Offline

 

#2 2019-09-29 01:29:55 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11613
Website

Re: Updating multiple TextView objects

To use a loop you have to create a list with the text items

Applescript:


property textViewItem_1 : missing value
property textViewItem_2 : missing value
property textViewItem_3 : missing value

set textItems to {textViewItem_1, textViewItem_2, textViewItem_3}

repeat with a from 1 to count textItems
   set currentItem to item a of textItems
   (currentItem's setStringValue:("test" & a))
end repeat


regards

Stefan

Offline

 

#3 2019-09-29 02:37:22 pm

AoRaToS
Member
From:: Greece
Registered: 2019-09-01
Posts: 8
Website

Re: Updating multiple TextView objects

Hello StefanK,

That worked, thank you very much!

Offline

 

#4 2019-10-07 08:17:19 pm

technomorph
Member
Registered: 2017-12-14
Posts: 124

Re: Updating multiple TextView objects

You could also in interface builder bind them to
The Class
With the key of the Property in the Class

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)