In REALBasic, how do I loop through all of the objects in Window1? Is there some array property of Window1 with all of its children? Also, how do you set custom properties of objects: e.g. Me.isFlamingo = true Thanks in advance!
REALBasic Questions
359 views Asked by Leticia Meyer At
2
There are 2 answers
0
On
Adding properties to a built-in class like a pushbutton can be done in two ways. The better way would be to subclass the PushBustton class and to add properties to the subclass like you would with any custom class. The other, somewhat uglier way would be to use a pair of overloaded functions like this:
Function isFlamingo(Extends ByRef pb As PushButton) As Boolean
Dim flamingo As Boolean
//Do stuff to figure out if the PushButton is Flamingo-y
//and Return a Boolean based on the result
Return flamingo
End Function
And:
Sub isFlamingo(Extends ByRef pb As PushButton, Assigns b As Boolean)
If b Then
//Do stuff that makes the PushButton flamingo-y
Else
//Do stuff that makes the PushButton not flamingo-y
End If
End Sub
To iterate through the controls on a window, use code like this:
(For this example, be sure to add at least one ListBox to the Window.)
Properties are set just like you describe: ObjectInstance.PropertyName.
If you are in the event of an object that has been dragged to the window, then you can modify its properties using Me.PropertyName. Otherwise you would use the object name.