Animating views 3, Dragging a view 3, Dragging and dropping with views 3 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 124

Advertising
background image

C H A P T E R 3

Views

3-40

Using Views

Animating Views

3

There are four view methods that perform special animation effects on views. They
are summarized here:

Effect

—performs any animation that can be specified in the

viewEffect

slot.

SlideEffect

—slides a whole view or its contents up or down.

RevealEffect

—slides part of a view up or down.

Delete

—crumples a view and tosses it into a trash can.

Note that these animation methods only move bits around on the screen. They do
not change the actual bounds of a view, or do anything to a view that would change
its contents. When you use any of these methods, you are responsible for supplying
another method that actually changes the view bounds or contents. Your method is
called just before the animation occurs.

Dragging a View

3

Dragging a view means allowing the user to move the view by tapping on it,
holding the pen down, and dragging it to a new location on the screen. To drag a
view, send the view a

Drag

message.

Dragging and Dropping with Views

3

Dragging and dropping a view means allowing a user to drag an item and drop it
into another view.

To enable dragging and dropping capability, you must first create a frame that
contains slots that specify how the drop will behave. For example, you specify the
types of objects that can be dropped into a view, if any. Examples include

'text

or

'picture

. See the

dragInfo

parameter to the

DragAndDrop

method

(page 2-46) in the Newton Programmer’s Reference for a complete description
of the slots.

You must set up code to handle a drag and drop in one of two ways: either add
code to create a frame and code to call

DragAndDrop

’s view method in each

source and destination view that accepts a drag and drop message, or you can
create a proto and use it as a template for each view.

Each view must also have the following methods. The system calls these methods
in the order listed.

ViewGetDropTypesScript

— is sent to the destination view. It is called

repeatedly while the pen is down.

ViewGetDropTypesScript

is passed the

current location as the dragged item is moved from its source location to its
destination location. An array of object types is also returned. In this method,
you must return an array of object types that can be accepted by that location.

Advertising