This question implies correctly that I do not understand computed
properties. When does the Set code run?
I tried to follow along with the example below from the User's Guide.
I created the custom control class as in the example.
The Get method seems to run when you have the computed property in
the code. That makes sense to me. When the computed property is in
the code (such as If DoesCrazyStuff then me.Enabled=False_______ the
value of DoesCrazyStuff is obtained by running the Get method.
The example confused me.
If I left the Set code out all together the button seemed to behave
in the same fashion. I could not detect that the Set code ever ran
and why would I not simply write the code:
If mDoesTheCrazies then me.Enabled=False etc. Why would I being
fooling with computed properties anyway?
To make the button behave in the desired frustrating way, I had to
put mDoesTheCrazies=true in the Open event whether or not the Set
code existed
Example supplies in the User's Guide:
Here is a simple example of a computed property in a custom control
class. It implements
an annoying PushButton control that disables itself whenever the mouse
pointer enters its region and enables itself when the mouse pointer
exits its region.
First, add a class to the Project Editor and set its Super class to
PushButton.
Double-click it to open its Code Editor. Add a property to the class
called
mDoesTheCrazies and give it a data type of Boolean. Then add a Computed
Property to the class called DoesCrazyStuff and also give it a data
type of Boolean.
Expand DoesCrazyStuff in the Code Editor browser and enter the
following line into
its Get method:
Return mDoesTheCrazies
It gets the current value in the ‘regular’ property, mDoesTheCrazies.
The Set method passes the current value in as the parameter, Value.
Enter the
following line as the Set method:
mDoesTheCrazies = Value
In the MouseEnter event for the custom PushButton class, add the code:
If DoesCrazyStuff then me.Enabled=False
In the MouseExit event, enter the line:
If DoesCrazyStuff then me.Enabled=True
In other words, the “regular” property, mDoesTheCrazies, stores the
boolean value
that is set by the computed property. The Get method gets the current
value of
mDoesTheCrazies. The MouseEnter and MouseExit methods control the
Enabled
property of the custom PushButton depending on the computed property.
_______________________________________________
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>