beautypg.com

Redirecting scrolling messages 3, Working with view highlighting 3 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 126

background image

C H A P T E R 3

Views

3-42

Using Views

In the latter kind of scrolling, the child views are moved within the parent view by
changing their view bounds. Newly visible views will be opened for the first time,
and views which have scrolled completely out-of-view will be closed. The
viewOriginX and viewOriginY slots are not used.

For information about techniques you can use to optimize scrolling so that it
happens as fast as possible, see “Scrolling” (page 3-46), and “Optimizing View
Performance” (page 3-44).

Redirecting Scrolling Messages

3

You can redirect scrolling messages from the base view to another view. Scrolling
and overview messages are sent to the frontmost view; this is the same view that is
returned if you call

GetView('viewFrontMost)

.

The

viewFrontMost

view is found by looking recursively at views that have

both the

vVisible

and

vApplication

bits set in their

viewFlags

. This

means that you can set the

vApplication

bit in a descendant of your base view,

and as long as

vApplication

is set in all of the views in the parent chain for that

view, the scrolling messages will go directly to that view. The

vApplication

bit

is not just for base views, despite what the name might suggest.

If your situation is more complex, where the view that needs to be scrolled cannot
have

vApplication

set or is not a descendant of your base view, you can have the

base view’s scrolling scripts call the appropriate scripts in the view you wish scrolled.

Working With View Highlighting

3

A highlighted view is identified visually by being inverted. That is, black and white
are reversed.

To highlight or unhighlight a view, send the view the

Hilite

message.

To highlight or unhighlight a single view from a group, send the view the

HiliteUnique

message. (The group is defined as all of the child views of one

parent view.)

To highlight a view when the current pen position is within it, send the view the

TrackHilite

message. The view is unhighlighted when the pen moves outside

the view bounds. If the view is a button, you can send the view the

TrackButton

message to accomplish the same task.

To get the view containing highlighted data, you can call the global function

HiliteOwner

; to get the highlighted text use

GetHiliteOffsets

.

To highlight some or all of the text in a paragraph, you can use the

SetHilite

method.