new Message(event)
A class which represents normalized event.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
event |
Event | Object | A DOM Event object or custom event object. See http://www.w3.org/TR/DOM-Level-3-Events/ for the DOM event details. If use the custom event, see below the table.
|
- Since:
-
- 2.0.0
Example
var message = new caph.event.Message({ type: 'click', source: element, bubbles: false, detail: 0 });
Methods
-
getDetail() → {*}
-
Gets the detail information about the event.
- Since:
-
- 2.0.0
Returns:
- Type
- *
Example
var message = new caph.event.Message({ type: 'click' }); var detail = message.getDetail();
-
getRelated() → {Object}
-
Gets the secondary source related to event.
- Since:
-
- 2.0.0
Returns:
- Type
- Object
Example
var message = new caph.event.Message({ type: 'click' }); var element = message.getRelated();
-
getSource() → {Object}
-
Gets the source to which the event was originally dispatched.
- Since:
-
- 2.0.0
Returns:
- Type
- Object
Example
var message = new caph.event.Message({ type: 'click' }); var element = message.getSource();
-
getTimeStamp() → {Number}
-
Gets the time that the event was created.
- Since:
-
- 2.0.0
Returns:
- Type
- Number
Example
var message = new caph.event.Message({ type: 'click' }); var timeStamp = message.getTimeStamp();
-
getType() → {String}
-
Gets the event type.
- Since:
-
- 2.0.0
Returns:
- Type
- String
Example
var message = new caph.event.Message({ type: 'click' }); var type = message.getType();
-
isBubbles() → {Boolean}
-
Determines a boolean indicating whether the event bubbles up. If the bubbles is false, the event is broadcasted to all children.
- Since:
-
- 2.0.0
Returns:
- Type
- Boolean
Example
var message = new caph.event.Message({ type: 'click' }); var isBubbles = message.isBubbles();
-
isPropagationStopped() → {Boolean}
-
Determines whether the bubbling of the event has been canceled
- Since:
-
- 2.0.0
Returns:
- Type
- Boolean
Example
var message = new caph.event.Message({ type: 'click' }); var stopped = message.isPropagationStopped();
-
key() → {Object}
-
Gets the major keyboard event properties such as key code, type and boolean values which indicate whether ctrl, alt, shift or meta key is pressed.
- Since:
-
- 2.0.0
Returns:
Object Details {Number} code A system and implementation dependent numerical code identifying the unmodified value of the pressed key. {String} type A string identifying a system and implementation dependent numerical code depending on key mapping. Default key mapping string consists of 'left', 'up', 'right', 'down', 'enter', 'n0', 'n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9'. These strings are compatible with both PC and Tizen TV because they are using same key code. It also provides additional key mapping strings such as 'power', 'source', 'hdmi', 'ttxMix', 'preCh', 'mute', 'chList', 'volDown', 'volUp', 'chDown', 'chUp', 'home', 'menu', 'guide', 'tools', 'info', 'return', 'exit', 'red', 'green', 'yellow', 'blue', 'rewind', 'pause', 'ff', 'rec', 'play', 'stop' used by Tizen TV remote controller. See caph.event.key.TYPE {Boolean} ctrl A boolean indicating whether the Ctrl key was active when the key event was generated or not. {Boolean} alt A boolean indicating whether the Alt key was active when the key event was generated or not. {Boolean} shift A boolean indicating whether the Shift key was active when the key event was generated or not. {Boolean} meta A boolean indicating whether the Meta (or Command, on Mac) key was active when the key event was generated or not. {Boolean} power, source, hdmi, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, ttxMix, preCh, mute, chList, volDown, volUp, chDown, chUp, home, menu, guide, tools, info, left, up, right, down, enter, return, exit, red, green, yellow, blue, rewind, pause, ff, rec, play, stop A boolean indicating whether each key code mapping string is pressed or not. These strings are provided by default. It depends on the key mapping setting. If you set another key mapping, property name will be changed according to your setting. See caph.event.key.TYPE - Type
- Object
Example
var message = new caph.event.Message({ type: 'keydown' }); if (message.key().enter) { console.log('enter!'); }
-
mouse() → {Object}
-
Gets the major mouse event properties such as coordinates, wheel direction and boolean values which indicate whether left, middle and right button is clicked.
- Since:
-
- 2.0.0
Returns:
Object Details {Boolean} left A boolean indicating whether the left button was pressed or not. {Boolean} middle A boolean indicating whether the middle button was pressed or not. {Boolean} right A boolean indicating whether the right button was pressed or not. {Boolean} ctrl A boolean indicating whether the Ctrl key was active when the key event was generated or not. {Boolean} alt A boolean indicating whether the Alt key was active when the key event was generated or not. {Boolean} shift A boolean indicating whether the Shift key was active when the key event was generated or not. {Boolean} meta A boolean indicating whether the Meta (or Command, on Mac) key was active when the key event was generated or not. {Number} screenX The X coordinate of the mouse position relative to the user's physical screen. {Number} screenY The Y coordinate of the mouse position relative to the user's physical screen. {Number} clientX The X coordinate of the mouse position relative to the browser's visible viewport. {Number} clientY The Y coordinate of the mouse position relative to the browser's visible viewport. {Number} offsetX The X coordinate of the mouse position relative to the target element. {Number} offsetY The Y coordinate of the mouse position relative to the target element. {Number} pageX The X coordinate of the mouse position relative to the html document. {Number} pageY The Y coordinate of the mouse position relative to the html document. - Type
- Object
Example
var message = new caph.event.Message({ type: 'click' }); if (message.mouse().offsetX > 100) { message.stopPropagation(); }
-
preventDefault()
-
Cancels the original event if cancelable.
- Since:
-
- 2.0.0
Example
var message = new caph.event.Message({ type: 'click' }); message.preventDefault();
-
setDetail(detail)
-
Sets the detail information about the event.
Parameters:
Name Type Description detail
* The detail information about the event.
- Since:
-
- 2.0.0
Example
var message = new caph.event.Message({ type: 'click' }); message.setDetail({ code: 0, message: 'success' });
-
setRelated(related)
-
Sets the secondary source related to event.
Parameters:
Name Type Description related
Object The secondary source related to event. It depends on the type of event. For example, if the event is a focus event, the source is receiving the focus and the secondary source is losing the focus. See the "5.2.3 Document Focus and Focus Context" section in http://www.w3.org/TR/DOM-Level-3-Events/ for details.
- Since:
-
- 2.0.0
Throws:
Will throw an error if the related property is already set.
Example
var message = new caph.event.Message({ type: 'click' }); message.setRelated(document.getElementById('id'));
-
setSource(source)
-
Sets the source to which the event was originally dispatched.
Parameters:
Name Type Description source
Object The source to which the event was originally dispatched
- Since:
-
- 2.0.0
Throws:
Will throw an error if the source property is already set.
Example
var message = new caph.event.Message({ type: 'click' }); message.setSource(document.getElementById('id'));
-
stopPropagation()
-
Keeps the rest of the handlers from being executed and prevents the event from bubbling up.
- Since:
-
- 2.0.0
Example
var message = new caph.event.Message({ type: 'click' }); message.stopPropagation();