On Dec 29, 2006, at 9:46 AM, Chuck Pelto wrote:
On Dec 29, 2006, at 8:18 AM, CV wrote:
On Dec 29, 2006, at 6:19 AM, Chuck Pelto wrote:
Greetings All,
Has REALbasic developed a variable that can be used to hold a
reference to a Window?
I asked this about a year ago as it seemed to me that such a
capability would be beneficial for creating reusable objects;
instead of having to hardwire in a window reference you
established the variable as a property and then loaded that
property with whatever window you wanted to refer to.
Happy New Year....
As described above, this has always been possible and is commonly
done. Perhaps you're suggesting a new wrinkle that I'm not grasping:
Add a property to Window2, for example: MyWindow as Window1
Then initialize it as you wish, for example:
MyWindow = new Window1 // MyWindow now holds a ref to Window1
Then you can access Window1 elements within Window2 as:
self.MyWindow.Whatever.
Or, from outside Window2 as: Window2.MyWindow.Whatever
If you want a more generic property, dim the property in Window2 as:
MyWindow as Window
You can assign any Window instance to MyWindow, and access any
element of the Window as for example:
MyWindow.Top = 5
But if you want access to a unique element that you have added to
say, Window1, then you need to cast MyWindow to a Window1:
If MyWindow IsA Window1 then
Window1(MyWindow).MyWindow1Method
End
Perhaps I'm not describing it properly.
I understand the new Window1 approach.
What I'm dealing with here is an existing Window.
I have several Windows.
Window1
Window2
Window3
In Window1 I have declared a property known as relatedWindow as Window
I set relatedWIndow to Window2 by the following:
relatedWindow = Window2
Then I try to set values of properties, e.g., a string property, in
Window2 via the relatedWindow property by:
relatedWindow.aProperty = "Something or other...."
Right, that reflects what I was trying to explain. RelatedWindow is
declared as Window, so it exposes <only> the properties/methods
belonging to Rb's Window class(those listed in the
LanguageReference). So you can do things like RelatedWindow.Top = 5.
But to expose methods/properties that that you have added to Window2,
which are not part of Rb's Window class, you have to cast
RelatedWindow from a Window to a Window2:
Window2(RelatedWindow).aProperty = "Something or other..."
That works provided RelatedWindow actually holds an instance of
Window2 at the time of the reference call. Otherwise the compiler
will balk. Since you may also intend to assign Window2 and Window3
into RelatedWindow then you will probably need to check using IsA
before addressing methods/properties unique to them or if assigning
unique values:
If RelatedWindow IsA Window2 then
Window2(RelatedWindow).aProperty = "Hansel" // elements or
assignments unique to Window2
Elseif RelatedWindow IsA Window3 then
Window3(RelatedWindow).aProperty = "Gretel" // elements or
assignments unique to Window3
End
The point to keep in mind is that the dim statement controls the
elements that the object can expose directly within the inheritance
hierarchy.
Best,
Jack
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>