15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<br />

<br />

moveAbove(layerObject)<br />

moveBelow(layerObject)<br />

Compatibility ✓<br />

Chapter 15 ✦ The NN4 Layer Object (Chapter 31)<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Example<br />

You can see the layerObject.moveAbove() method at work in Listing 31-1.<br />

moveBy(deltaX,deltaY)<br />

moveTo(x,y)<br />

moveToAbsolute(x,y)<br />

Compatibility ✓<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Example<br />

Listing 31-11 shows a demonstration of the layerObject.moveTo() method. It<br />

is a simple script that enables you to click and drag a layer around the screen. The<br />

script employs the coordinate values of the mouseMove event; after compensating<br />

for the offset within the layer at which the click occurs, the script moves the layer<br />

to track the mouse action.<br />

I want to present this example for an additional reason: to explain an important<br />

user interface difference between Windows and Macintosh versions of NN4. In<br />

Windows versions, you can click and hold the mouse button down on an object and<br />

let the object receive all the mouseMove events as you drag the cursor around the<br />

screen. On the Macintosh, however, NN4 tries to compensate for the lack of a second<br />

mouse button by popping up a context-sensitive menu at the cursor position<br />

when the user holds the mouse button down for more than just a click. To prevent<br />

the pop-up menu from appearing, the engage() method invoked by the<br />

onMouseDown event handler ends with return false.<br />

Notice in the following listing how the layer captures a number of mouse events.<br />

Each one plays an important role in creating a mode that is essentially like a<br />

mouseStillDown event (which doesn’t exist in NN4’s event model). The mouseDown<br />

event sets a Boolean flag (engaged) indicating that the user clicked down in the<br />

463<br />

document.layerObject.moveBy()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!