We will explore the cut,copy and paste events by exploring addEvents and NativeEvents from mootools library.

Objective: Register multiple events ( cut,copy and paste ) to a text box.


<!DOCTYPE html>
		<script src="mootools-core-1.4.5-full-compat.js"></script>
		<div style="margin:0 auto;float:left">Try copy / cut and paste into this text box</div>
		<input type="text" id="target" value="testing"/>
			Element.NativeEvents.cut = 1;
			Element.NativeEvents.copy = 1;
				$('target').addEvents(	{
					alert('Cut , could bleed your hand');
					alert('Copy, is bad karma');
					alert('Paste, is sticking');

Explanation:  We have a text box with id "target" , and we need to register a multiple events to "target" textbox. When we have multiple events to be registered we use addEvents function, in line 15 we have the events registered. However we could have used the addEvent funtion to register individual events, but addEvents turns out to be easier. Do note the line in 13 and 14, we have used Element.NativeEvents.cut and Elements.NativeEvents.copy and assigned value 1 to each. Might be wondering why we need such thing. Well, these two events are not supported by Mootools library, as of 1.4.5 , but Mootools opens up a dimention to register any events which is not supported by Mootools , but by the browser, by assigning either 0 , 1 or 2. Do note that, paste is supported by Mootools , so it is not required to add to the Elements.NativeEvents.


Try copy / cut and paste into this text box

Task: Try out registering the events on windows instead of the text box.