beautypg.com

Changing the values in viewformat 3, Determining which view item is selected 3 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 121

background image

C H A P T E R 3

Views

Using Views

3-37

needed values. Your template is only a two-slot object in RAM. The user proto
resides in the package with the rest of your application. The conventional, RAM-
wasting alternative would have been:

template := Clone(PT_dynoTemplate);

template.viewBounds := RelBounds(x, y, width, height);

Note that for creating views arranged in a table, there is a function called

LayoutTable

that calculates all the bounds. It returns an array of templates.

Making a Picker View

3

To create a transient pop-up list view, or picker, you can use the function

PopupMenu

. This kind of view pops up on the screen and is a list from which the

user can make a choice by tapping it. As soon as the user chooses an item, the
picker view is closed.

You can also create a picker view by defining a template using the

protoPicker

view proto. See “Pickers, Pop-up Views, and Overviews” (page 6-1) for
information on

protoPicker

and

PopupMenu

.

Changing the Values in viewFormat

3

You can change the values in the

viewFormat

slot of a view without closing and

reopening a view. Use the

SetValue

function to update the view with new

settings. For example:

SetValue(myView, ‘viewFormat, 337)

// 337 = vfFillWhite + vfFrameBlack+vfPen(1)

SetValue

, among other things, calls

Dirty

if necessary, so you don’t need to

call it to do a task that the view system already knows about, such as changing

viewBounds

or text slots in a view.

Determining Which View Item Is Selected

3

To determine which view item is selected in a view call

GetHiliteOffsets

.

You must call this function in combination with the

HiliteOwner

function.

When you call

GetHiliteOffsets

, it returns an array of arrays. Each item in

the outer array represents selected subviews, as in the following example:

x:= gethiliteoffsets()

#440CA69 [[{#4414991}, 0, 2],

[{#4417B01}, 0, 5],

[{#4418029}, 1, 3]}