background image
C H A P T E R 3
Views
About Views
3-25
_parent
Contains a reference to the parent template. This slot is
created when the view opens. Note that it's best to use the
Parent
function to access the parent view at run time, rather
than directly referencing the
_parent
slot.
stepChildren
Contains an array that holds references to each of the
template's child templates. This slot is created and set
automatically when you graphically create child views in
NTK. This slot is for children that you add to a template.
viewChildren
Contains an array that holds references to each of a system
proto's child templates. Because this slot is used by system
protos, you should never modify it or create a new one with
this name. If you do so, you may be inadvertently overriding
the children of a system proto. An exception to this rule
occurs for clEditView; you might want to edit the
viewChildren slot of a clEditView. See Table 2-1, "View
class constants," (page 2-2) in Newton Programmer's Guide
for details.
The reason for the dual child view slots is that the
viewChildren
slot is used by
the system protos to store their child templates. If you create a view derived from
one of the system protos and change the
viewChildren
slot (for example, to add
your own child templates programmatically), you would actually be creating a new
viewChildren
slot that would override the one in the proto, and the child
templates of the proto would be ignored.
The
stepChildren
slot has been provided instead as a place for you to put your
child templates, if you need to do so from within a method. By adding your
templates to this slot, the
viewChildren
slot of the proto is not overridden. Both
groups of child views are created when the parent view is instantiated.
If you are only creating views graphically using the Newton Toolkit palette, you don't
need to worry about these internal details. The Newton Toolkit always uses the
stepChildren
slot for you.
You may see either
viewChildren
,
stepChildren
, or both slots when you
examine a template at run time in the Newton Toolkit Inspector window. Child
templates can be listed in either slot, or both. When a view is instantiated, all the
child views from both of these two slots are also created. Note that the templates in
the
viewChildren
slot are instantiated first, followed by the templates in the
stepChildren
slot.
If you are adding child views in a method that will not be executed until run time,
you need to use the
stepChildren
slot to do this. If there isn't a
stepChildren
slot, create one and put your views there.
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна