Mootools [6]-Event
Description: mootools defines an event class, which provides an extension of the event object event of the original window. When used, you can pass in the original event object as the event constructor parameter:
VaR event = new event (event );
In this way, the returned event contains all the extended functions of mootools. The attributes and methods of the extension are as follows:
======================================== Property ================ ====================
Shift: when the trigger event is a keyboard button event, determine whether the pressed button is a shift key.
Example:
$ ('Mylink'). onkeydown = function (event ){
VaR event = new event (event); // extended Event
Alert (event. Shift); // if the key is shift, alert returns true
};
[Control, ALT, Meta usage is the same as shift.]
Code: when the trigger event is a keyboard button event, press the key's keycode
Page. X: When a mouse event is triggered, the mouse is relative to the X of the entire form.
Page. Y: When a mouse event is triggered
Client. X: When a mouse event is triggered, the mouse is relative to y of the current field of view.
Client. Y: When a mouse event is triggered, the mouse is relative to y of the current field of view.
(In general, the effects of client. X and client. Y are the same as those of page. Y and page. Y. However, when a scroll bar appears on the form, the effects of the two are different .)
Example:
$ ('Myinput'). addevent ('click', function (event ){
VaR event = new event (event );
Alert (event. Page. Y + "|" + event. Client. y );
});
Key: when the trigger event is a keyboard button event, press the name of the button, for example, "enter", "ESC", and so on.
Target: The Event element.
Relatedtarget: The reference object of the element object when a Mouseover or mouseout event occurs.
========================================== ======================
Method: Stop
Purpose: Stop the event execution.
Method: stoppropagation
Purpose: Stop event bubbling transmission.
Method: preventdefault
Purpose: Stop the default action of an event.
Thanks to the introduction of event, mootools has extended a method for function:
Bindwithevent has the same usage as the bindaseventlistener method of function. The difference is that the bindaseventlistener method is passed to the event listener as the original event object, while bindwithevent is the event instance pair.