Apple Newton Utilities Guia do Utilizador Página 118

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 942
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 117
CHAPTER 3
Views
3-34 Using Views
Showing a Hidden View 3
In many cases, you might think that you need to create a view dynamically. However,
if the template can be dened at compile time, it’s easier to do that and ag the
view as not visible. At the appropriate time, send it the
Open message to show it.
The typical example of this is a slip, which you can usually dene at compile time.
Using the Newton Toolkit (NTK), simply do not check the
vVisible ag in the
viewFlags slot of the view template. This will keep the view hidden when the
application is opened.
Also, it is important to declare this view in your application base view. For
information on declaring a view, see the section “View Instantiation” (page 3-26).
When you need to display the view, send it the
Open message using the name
under which you have declared it (for example,
myView:Open()).
This solution even works in cases where some template slots cannot be set until run
time. You can dynamically set slot values during view instantiation in any of the
following view methods: ViewSetupFormScript,
ViewSetupChildrenScript, and ViewSetupDoneScript. You can also set
values in a declared view before sending it the
Open message.
Adding to the stepChildren Array 3
If it is not possible to dene the template for a view at compile time, the next best
solution is to create the template (either at compile time or run time) and add it to
the
stepChildren array of the parent view using the
ViewSetupChildrenScript method. This way, the view system takes care of
creating the view at the appropriate time (when the child views are shown).
For example, if you want to dynamically create a child view, you rst dene the
view template as a frame. Then, in the
ViewSetupChildrenScript method of
its parent view, you add this frame to the
stepChildren array of the parent view.
To ensure that the
stepChildren array is in RAM, use this code:
if not HasSlot(self, 'stepChildren) then
self.stepChildren := Clone(self.stepChildren);
AddArraySlot(self.stepChildren, myDynamicTemplate);
The if statement checks whether the stepChildren slot already exists in the
current view (in RAM). If it does not, it is copied out of the template (in ROM)
into RAM. Then the new template is appended to the array.
All of this takes place in the
ViewSetupChildrenScript method of the parent
view, which is before the
stepChildren array is read and the child views are
created.
Vista de página 117
1 2 ... 113 114 115 116 117 118 119 120 121 122 123 ... 941 942

Comentários a estes Manuais

Sem comentários