Mootools framework [6]-Event: analysis of main attributes and Methods

Source: Internet
Author: User
Tags mootools

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.