Enterprise Tookit for Acrobat Products > Mobile > (Android | iOS)

JavaScript for Acrobat Reader Mobile API Reference (iOS)

File: Event.js

  1. /*************************************************************************
  2. *
  3. * ADOBE CONFIDENTIAL
  4. * ___________________
  5. *
  6. * Copyright 2012 Adobe Systems Incorporated
  7. * All Rights Reserved.
  8. *
  9. * NOTICE: All information contained herein is, and remains
  10. * the property of Adobe Systems Incorporated and its suppliers,
  11. * if any. The intellectual and technical concepts contained
  12. * herein are proprietary to Adobe Systems Incorporated and its
  13. * suppliers and are protected by trade secret or copyright law.
  14. * Dissemination of this information or reproduction of this material
  15. * is strictly forbidden unless prior written permission is obtained
  16. * from Adobe Systems Incorporated.
  17. *
  18. **************************************************************************/
  19. /**
  20. * All JavaScript scripts are executed as the result of a particular event. For each of
  21. * these events, JavaScript creates an event object. During the occurrence of each event,
  22. * you can access this object to get and possibly manipulate information about the current
  23. * state of the event.
  24. *
  25. * @class Event
  26. */
  27. function Event()
  28. {
  29. };
  30. Event.prototype =
  31. {
  32. /**
  33. * A string specifying the change in value that the user has just typed. A JavaScript may
  34. * replace part or all of this string with different characters. The change may take the form
  35. * of an individual keystroke or a string of characters (for example, if a paste into the field
  36. * is performed).
  37. *
  38. * @property change
  39. * @type {String}
  40. */
  41. get change()
  42. {
  43. return ARJavaScriptEvent.change;
  44. },
  45. set change(_val)
  46. {
  47. if (typeof(_val) == "string")
  48. {
  49. ARJavaScriptEvent.change = _val;
  50. }
  51. },
  52. /**
  53. * Used for validation. Indicates whether a particular event in the event chain should
  54. * succeed. Set to false to prevent a change from occurring or a value from committing.
  55. * The default is true.
  56. *
  57. * @property rc
  58. * @type {Boolean}
  59. *
  60. */
  61. get rc()
  62. {
  63. var returnVal;
  64. var rc = ARJavaScriptEvent.rc;
  65. if (rc == 1)
  66. {
  67. returnVal = true;
  68. }
  69. else
  70. {
  71. returnVal = false;
  72. }
  73. return returnVal;
  74. },
  75. set rc(_val)
  76. {
  77. if (typeof(_val) == "boolean")
  78. {
  79. ARJavaScriptEvent.rc = _val;
  80. }
  81. },
  82. /**
  83. * The ending position of the current text selection during a keystroke event.
  84. *
  85. * @property selEnd
  86. * @type {Number}
  87. * @readOnly
  88. */
  89. get selEnd()
  90. {
  91. return ARJavaScriptEvent.selEnd;
  92. },
  93. /**
  94. * The starting position of the current text selection during a keystroke event.
  95. *
  96. * @property selStart
  97. * @type {Number}
  98. * @readOnly
  99. */
  100. get selStart()
  101. {
  102. return ARJavaScriptEvent.selStart;
  103. },
  104. /**
  105. * Returns true if errors should be silenced instead of displaying an alert.
  106. *
  107. * @private
  108. * @property silenceErrors
  109. * @type {Boolean}
  110. * @readOnly
  111. */
  112. get silenceErrors()
  113. {
  114. var returnVal;
  115. var silenceErrors = ARJavaScriptEvent.silenceErrors;
  116. if (silenceErrors == 1)
  117. {
  118. returnVal = true;
  119. }
  120. else
  121. {
  122. returnVal = false;
  123. }
  124. return returnVal;
  125. },
  126. /**
  127. * The Field object that triggered the calculation event. This object is usually different from the
  128. * target of the event, which is the field that is being calculated.
  129. *
  130. * @property source
  131. * @type {Object}
  132. * @readOnly
  133. */
  134. get source()
  135. {
  136. var returnVal = null;
  137. var source = ARJavaScriptEvent.source;
  138. if (source)
  139. {
  140. returnVal = new Field(ARJavaScriptEvent.source);
  141. }
  142. return returnVal;
  143. },
  144. /**
  145. * The target object that triggered the event. In all mouse, focus, blur, calculate, validate, and
  146. * format events, it is the Field object that triggered the event. In other events, such as page open
  147. * and close, it is the Doc or this object.
  148. *
  149. * @property target
  150. * @type {Object}
  151. * @readOnly
  152. */
  153. get target()
  154. {
  155. var returnVal = null;
  156. var target = ARJavaScriptEvent.target;
  157. if (target)
  158. {
  159. returnVal = new Field(ARJavaScriptEvent.target);
  160. }
  161. return returnVal;
  162. },
  163. /**
  164. * Tries to return the name of the target object. Can be used for debugging purposes to help identify
  165. * the code causing exceptions to be thrown. Common values of targetName include:
  166. *
  167. * The folder-level script file name for App/Init events
  168. * The document-level script name forDoc/Open events
  169. * The PDF file name being processed for Batch/Exec events
  170. * The field name for Field events
  171. * The menu item name for Menu/Exec events
  172. * The screen annotation name for Screen events (multimedia events)
  173. *
  174. * @property targetName
  175. * @type {String}
  176. * @readOnly
  177. */
  178. get targetName()
  179. {
  180. return ARJavaScriptEvent.targetName;
  181. },
  182. /**
  183. * This property has different meanings for different field events:
  184. *
  185. * For the Field/Validate event, it is the value that the field contains when it is committed.
  186. * For a combo box, it is the face value, not the export value.
  187. *
  188. * For a Field/Calculate event, JavaScript should set this property. It is the value that the
  189. * field should take upon completion of the event.
  190. *
  191. * For a Field/Format event, JavaScript should set this property. It is the value used when generating
  192. * the appearance for the field. By default, it contains the value that the user has committed. For a
  193. * combo box, this is the face value, not the export value.
  194. *
  195. * For a Field/Keystroke event, it is the current value of the field. If modifying a text field, for
  196. * example, this is the text in the text field before the keystroke is applied.
  197. *
  198. * For Field/Blur and Field/Focus events, it is the current value of the field. During these two events,
  199. * event.value is read only. That is, the field value cannot be changed by setting event.value.
  200. *
  201. * @property value
  202. * @type {Any}
  203. */
  204. get value()
  205. {
  206. return ARJavaScriptEvent.value;
  207. },
  208. set value(_val)
  209. {
  210. if (_val == undefined || _val == null)
  211. _val = "";
  212. if (isNullOrUndefined(_val))
  213. _val = "";
  214. else
  215. _val = _val.toString();
  216. ARJavaScriptEvent.value = _val;
  217. },
  218. /**
  219. * Verifies the current keystroke event before the data is committed. It can be used to check target form
  220. * field values to verify, for example, whether character data was entered instead of numeric data. JavaScript
  221. * sets this property to true after the last keystroke event and before the field is validated.
  222. *
  223. * @property willCommit
  224. * @type {Boolean}
  225. * @readOnly
  226. */
  227. get willCommit()
  228. {
  229. var returnVal;
  230. var willCommit = ARJavaScriptEvent.willCommit;
  231. if (willCommit == 1)
  232. {
  233. returnVal = true;
  234. }
  235. else
  236. {
  237. returnVal = false;
  238. }
  239. return returnVal;
  240. }
  241. };
  242. // register undefined properties on the Event.prototype object
  243. registerUndefinedProperty(Event.prototype, 'event', 'changeEx');
  244. registerUndefinedProperty(Event.prototype, 'event', 'commitKey');
  245. registerUndefinedProperty(Event.prototype, 'event', 'fieldFull');
  246. registerUndefinedProperty(Event.prototype, 'event', 'keyDown');
  247. registerUndefinedProperty(Event.prototype, 'event', 'modifier');
  248. registerUndefinedProperty(Event.prototype, 'event', 'name');
  249. registerUndefinedProperty(Event.prototype, 'event', 'richChange');
  250. registerUndefinedProperty(Event.prototype, 'event', 'richChangeEx');
  251. registerUndefinedProperty(Event.prototype, 'event', 'richValue');
  252. registerUndefinedProperty(Event.prototype, 'event', 'shift');
  253. registerUndefinedProperty(Event.prototype, 'event', 'type');
  254. // instantiate object
  255. var event = new Event();

© 2013-15 Adobe Systems, Inc. All rights reserved. Use of these APIs including, the download of software, submission of comments, ideas, feature requests and techniques, and Adobe's rights to use such submitted materials, is governed by the Adobe.com Terms of Use and the Adobe Privacy Policy.