001package Torello.Browser; 002 003import java.util.*; 004import javax.json.*; 005import javax.json.stream.*; 006import java.io.*; 007 008import java.lang.reflect.Method; 009import java.lang.reflect.Parameter; 010import java.util.function.Function; 011 012import Torello.Java.Additional.*; 013import Torello.Java.JSON.*; 014 015import static Torello.Java.JSON.JFlag.*; 016 017import Torello.Java.StrCmpr; 018import Torello.JavaDoc.StaticFunctional; 019import Torello.JavaDoc.JDHeaderBackgroundImg; 020import Torello.JavaDoc.Excuse; 021 022/** 023 * <SPAN CLASS=COPIEDJDK><B><CODE>[No Description Provided by Google]</CODE></B></SPAN> 024 * 025 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 026 */ 027@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 028@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 029public class Input 030{ 031 // ******************************************************************************************** 032 // ******************************************************************************************** 033 // Class Header Stuff 034 // ******************************************************************************************** 035 // ******************************************************************************************** 036 037 038 // No Pubic Constructors 039 private Input () { } 040 041 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 042 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 043 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 044 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 045 046 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 047 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 048 // offically, two empty-vectors. One for String's, and the other for Classes. 049 050 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 051 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 052 053 static 054 { 055 for (Method m : Input.class.getMethods()) 056 { 057 // This doesn't work! The parameter names are all "arg0" ... "argN" 058 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 059 // 060 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 061 062 Vector<Class<?>> parameterTypesList = new Vector<>(); 063 064 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 065 066 parameterTypes.put( 067 m.getName(), 068 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 069 ); 070 } 071 } 072 073 static 074 { 075 Vector<String> v = null; 076 077 v = new Vector<String>(5); 078 parameterNames.put("dispatchDragEvent", v); 079 Collections.addAll(v, new String[] 080 { "type", "x", "y", "data", "modifiers", }); 081 082 v = new Vector<String>(15); 083 parameterNames.put("dispatchKeyEvent", v); 084 Collections.addAll(v, new String[] 085 { "type", "modifiers", "timestamp", "text", "unmodifiedText", "keyIdentifier", "code", "key", "windowsVirtualKeyCode", "nativeVirtualKeyCode", "autoRepeat", "isKeypad", "isSystemKey", "location", "commands", }); 086 087 v = new Vector<String>(1); 088 parameterNames.put("insertText", v); 089 Collections.addAll(v, new String[] 090 { "text", }); 091 092 v = new Vector<String>(5); 093 parameterNames.put("imeSetComposition", v); 094 Collections.addAll(v, new String[] 095 { "text", "selectionStart", "selectionEnd", "replacementStart", "replacementEnd", }); 096 097 v = new Vector<String>(16); 098 parameterNames.put("dispatchMouseEvent", v); 099 Collections.addAll(v, new String[] 100 { "type", "x", "y", "modifiers", "timestamp", "button", "buttons", "clickCount", "force", "tangentialPressure", "tiltX", "tiltY", "twist", "deltaX", "deltaY", "pointerType", }); 101 102 v = new Vector<String>(4); 103 parameterNames.put("dispatchTouchEvent", v); 104 Collections.addAll(v, new String[] 105 { "type", "touchPoints", "modifiers", "timestamp", }); 106 107 v = new Vector<String>(9); 108 parameterNames.put("emulateTouchFromMouseEvent", v); 109 Collections.addAll(v, new String[] 110 { "type", "x", "y", "button", "timestamp", "deltaX", "deltaY", "modifiers", "clickCount", }); 111 112 v = new Vector<String>(1); 113 parameterNames.put("setIgnoreInputEvents", v); 114 Collections.addAll(v, new String[] 115 { "ignore", }); 116 117 v = new Vector<String>(1); 118 parameterNames.put("setInterceptDrags", v); 119 Collections.addAll(v, new String[] 120 { "enabled", }); 121 122 v = new Vector<String>(5); 123 parameterNames.put("synthesizePinchGesture", v); 124 Collections.addAll(v, new String[] 125 { "x", "y", "scaleFactor", "relativeSpeed", "gestureSourceType", }); 126 127 v = new Vector<String>(12); 128 parameterNames.put("synthesizeScrollGesture", v); 129 Collections.addAll(v, new String[] 130 { "x", "y", "xDistance", "yDistance", "xOverscroll", "yOverscroll", "preventFling", "speed", "gestureSourceType", "repeatCount", "repeatDelayMs", "interactionMarkerName", }); 131 132 v = new Vector<String>(5); 133 parameterNames.put("synthesizeTapGesture", v); 134 Collections.addAll(v, new String[] 135 { "x", "y", "duration", "tapCount", "gestureSourceType", }); 136 } 137 138 139 // ******************************************************************************************** 140 // ******************************************************************************************** 141 // Types - Static Inner Classes 142 // ******************************************************************************************** 143 // ******************************************************************************************** 144 145 // public static class TimeSinceEpoch => Number 146 147 /** 148 * <CODE>[No Description Provided by Google]</CODE> 149 * <BR /> 150 * <BR /><B>EXPERIMENTAL</B> 151 */ 152 public static final String[] GestureSourceType = 153 { "default", "touch", "mouse", }; 154 155 /** <CODE>[No Description Provided by Google]</CODE> */ 156 public static final String[] MouseButton = 157 { "none", "left", "middle", "right", "back", "forward", }; 158 159 /** <CODE>[No Description Provided by Google]</CODE> */ 160 public static class TouchPoint 161 extends BaseType 162 implements java.io.Serializable 163 { 164 /** For Object Serialization. java.io.Serializable */ 165 protected static final long serialVersionUID = 1; 166 167 public boolean[] optionals() 168 { return new boolean[] { false, false, true, true, true, true, true, true, true, true, true, }; } 169 170 /** X coordinate of the event relative to the main frame's viewport in CSS pixels. */ 171 public final Number x; 172 173 /** 174 * Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to 175 * the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. 176 */ 177 public final Number y; 178 179 /** 180 * X radius of the touch area (default: 1.0). 181 * <BR /> 182 * <BR /><B>OPTIONAL</B> 183 */ 184 public final Number radiusX; 185 186 /** 187 * Y radius of the touch area (default: 1.0). 188 * <BR /> 189 * <BR /><B>OPTIONAL</B> 190 */ 191 public final Number radiusY; 192 193 /** 194 * Rotation angle (default: 0.0). 195 * <BR /> 196 * <BR /><B>OPTIONAL</B> 197 */ 198 public final Number rotationAngle; 199 200 /** 201 * Force (default: 1.0). 202 * <BR /> 203 * <BR /><B>OPTIONAL</B> 204 */ 205 public final Number force; 206 207 /** 208 * The normalized tangential pressure, which has a range of [-1,1] (default: 0). 209 * <BR /> 210 * <BR /><B>OPTIONAL</B> 211 * <BR /><B>EXPERIMENTAL</B> 212 */ 213 public final Number tangentialPressure; 214 215 /** 216 * The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0) 217 * <BR /> 218 * <BR /><B>OPTIONAL</B> 219 * <BR /><B>EXPERIMENTAL</B> 220 */ 221 public final Integer tiltX; 222 223 /** 224 * The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0). 225 * <BR /> 226 * <BR /><B>OPTIONAL</B> 227 * <BR /><B>EXPERIMENTAL</B> 228 */ 229 public final Integer tiltY; 230 231 /** 232 * The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0). 233 * <BR /> 234 * <BR /><B>OPTIONAL</B> 235 * <BR /><B>EXPERIMENTAL</B> 236 */ 237 public final Integer twist; 238 239 /** 240 * Identifier used to track touch sources between events, must be unique within an event. 241 * <BR /> 242 * <BR /><B>OPTIONAL</B> 243 */ 244 public final Number id; 245 246 /** 247 * Constructor 248 * 249 * @param x X coordinate of the event relative to the main frame's viewport in CSS pixels. 250 * 251 * @param y 252 * Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to 253 * the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. 254 * 255 * @param radiusX X radius of the touch area (default: 1.0). 256 * <BR /><B>OPTIONAL</B> 257 * 258 * @param radiusY Y radius of the touch area (default: 1.0). 259 * <BR /><B>OPTIONAL</B> 260 * 261 * @param rotationAngle Rotation angle (default: 0.0). 262 * <BR /><B>OPTIONAL</B> 263 * 264 * @param force Force (default: 1.0). 265 * <BR /><B>OPTIONAL</B> 266 * 267 * @param tangentialPressure The normalized tangential pressure, which has a range of [-1,1] (default: 0). 268 * <BR /><B>OPTIONAL</B> 269 * <BR /><B>EXPERIMENTAL</B> 270 * 271 * @param tiltX The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0) 272 * <BR /><B>OPTIONAL</B> 273 * <BR /><B>EXPERIMENTAL</B> 274 * 275 * @param tiltY The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0). 276 * <BR /><B>OPTIONAL</B> 277 * <BR /><B>EXPERIMENTAL</B> 278 * 279 * @param twist The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0). 280 * <BR /><B>OPTIONAL</B> 281 * <BR /><B>EXPERIMENTAL</B> 282 * 283 * @param id Identifier used to track touch sources between events, must be unique within an event. 284 * <BR /><B>OPTIONAL</B> 285 */ 286 public TouchPoint( 287 Number x, Number y, Number radiusX, Number radiusY, Number rotationAngle, 288 Number force, Number tangentialPressure, Integer tiltX, Integer tiltY, 289 Integer twist, Number id 290 ) 291 { 292 // Exception-Check(s) to ensure that if any parameters which are not declared as 293 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 294 295 if (x == null) BRDPC.throwNPE("x"); 296 if (y == null) BRDPC.throwNPE("y"); 297 298 this.x = x; 299 this.y = y; 300 this.radiusX = radiusX; 301 this.radiusY = radiusY; 302 this.rotationAngle = rotationAngle; 303 this.force = force; 304 this.tangentialPressure = tangentialPressure; 305 this.tiltX = tiltX; 306 this.tiltY = tiltY; 307 this.twist = twist; 308 this.id = id; 309 } 310 311 /** 312 * JSON Object Constructor 313 * @param jo A Json-Object having data about an instance of {@code 'TouchPoint'}. 314 */ 315 public TouchPoint (JsonObject jo) 316 { 317 this.x = ReadNumberJSON.get(jo, "x", false, true); 318 this.y = ReadNumberJSON.get(jo, "y", false, true); 319 this.radiusX = ReadNumberJSON.get(jo, "radiusX", true, false); 320 this.radiusY = ReadNumberJSON.get(jo, "radiusY", true, false); 321 this.rotationAngle = ReadNumberJSON.get(jo, "rotationAngle", true, false); 322 this.force = ReadNumberJSON.get(jo, "force", true, false); 323 this.tangentialPressure = ReadNumberJSON.get(jo, "tangentialPressure", true, false); 324 this.tiltX = ReadBoxedJSON.getInteger(jo, "tiltX", true); 325 this.tiltY = ReadBoxedJSON.getInteger(jo, "tiltY", true); 326 this.twist = ReadBoxedJSON.getInteger(jo, "twist", true); 327 this.id = ReadNumberJSON.get(jo, "id", true, false); 328 } 329 330 331 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 332 public boolean equals(Object other) 333 { 334 if (other == null) return false; 335 if (other.getClass() != this.getClass()) return false; 336 337 TouchPoint o = (TouchPoint) other; 338 339 return 340 Objects.equals(this.x, o.x) 341 && Objects.equals(this.y, o.y) 342 && Objects.equals(this.radiusX, o.radiusX) 343 && Objects.equals(this.radiusY, o.radiusY) 344 && Objects.equals(this.rotationAngle, o.rotationAngle) 345 && Objects.equals(this.force, o.force) 346 && Objects.equals(this.tangentialPressure, o.tangentialPressure) 347 && Objects.equals(this.tiltX, o.tiltX) 348 && Objects.equals(this.tiltY, o.tiltY) 349 && Objects.equals(this.twist, o.twist) 350 && Objects.equals(this.id, o.id); 351 } 352 353 /** Generates a Hash-Code for {@code 'this'} instance */ 354 public int hashCode() 355 { 356 return 357 Objects.hashCode(this.x) 358 + Objects.hashCode(this.y) 359 + Objects.hashCode(this.radiusX) 360 + Objects.hashCode(this.radiusY) 361 + Objects.hashCode(this.rotationAngle) 362 + Objects.hashCode(this.force) 363 + Objects.hashCode(this.tangentialPressure) 364 + Objects.hashCode(this.tiltX) 365 + Objects.hashCode(this.tiltY) 366 + Objects.hashCode(this.twist) 367 + Objects.hashCode(this.id); 368 } 369 } 370 371 /** 372 * <CODE>[No Description Provided by Google]</CODE> 373 * <BR /> 374 * <BR /><B>EXPERIMENTAL</B> 375 */ 376 public static class DragDataItem 377 extends BaseType 378 implements java.io.Serializable 379 { 380 /** For Object Serialization. java.io.Serializable */ 381 protected static final long serialVersionUID = 1; 382 383 public boolean[] optionals() 384 { return new boolean[] { false, false, true, true, }; } 385 386 /** Mime type of the dragged data. */ 387 public final String mimeType; 388 389 /** 390 * Depending of the value of <CODE>mimeType</CODE>, it contains the dragged link, 391 * text, HTML markup or any other data. 392 */ 393 public final String data; 394 395 /** 396 * Title associated with a link. Only valid when <CODE>mimeType</CODE> == "text/uri-list". 397 * <BR /> 398 * <BR /><B>OPTIONAL</B> 399 */ 400 public final String title; 401 402 /** 403 * Stores the base URL for the contained markup. Only valid when <CODE>mimeType</CODE> 404 * == "text/html". 405 * <BR /> 406 * <BR /><B>OPTIONAL</B> 407 */ 408 public final String baseURL; 409 410 /** 411 * Constructor 412 * 413 * @param mimeType Mime type of the dragged data. 414 * 415 * @param data 416 * Depending of the value of <CODE>mimeType</CODE>, it contains the dragged link, 417 * text, HTML markup or any other data. 418 * 419 * @param title Title associated with a link. Only valid when <CODE>mimeType</CODE> == "text/uri-list". 420 * <BR /><B>OPTIONAL</B> 421 * 422 * @param baseURL 423 * Stores the base URL for the contained markup. Only valid when <CODE>mimeType</CODE> 424 * == "text/html". 425 * <BR /><B>OPTIONAL</B> 426 */ 427 public DragDataItem(String mimeType, String data, String title, String baseURL) 428 { 429 // Exception-Check(s) to ensure that if any parameters which are not declared as 430 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 431 432 if (mimeType == null) BRDPC.throwNPE("mimeType"); 433 if (data == null) BRDPC.throwNPE("data"); 434 435 this.mimeType = mimeType; 436 this.data = data; 437 this.title = title; 438 this.baseURL = baseURL; 439 } 440 441 /** 442 * JSON Object Constructor 443 * @param jo A Json-Object having data about an instance of {@code 'DragDataItem'}. 444 */ 445 public DragDataItem (JsonObject jo) 446 { 447 this.mimeType = ReadJSON.getString(jo, "mimeType", false, true); 448 this.data = ReadJSON.getString(jo, "data", false, true); 449 this.title = ReadJSON.getString(jo, "title", true, false); 450 this.baseURL = ReadJSON.getString(jo, "baseURL", true, false); 451 } 452 453 454 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 455 public boolean equals(Object other) 456 { 457 if (other == null) return false; 458 if (other.getClass() != this.getClass()) return false; 459 460 DragDataItem o = (DragDataItem) other; 461 462 return 463 Objects.equals(this.mimeType, o.mimeType) 464 && Objects.equals(this.data, o.data) 465 && Objects.equals(this.title, o.title) 466 && Objects.equals(this.baseURL, o.baseURL); 467 } 468 469 /** Generates a Hash-Code for {@code 'this'} instance */ 470 public int hashCode() 471 { 472 return 473 Objects.hashCode(this.mimeType) 474 + Objects.hashCode(this.data) 475 + Objects.hashCode(this.title) 476 + Objects.hashCode(this.baseURL); 477 } 478 } 479 480 /** 481 * <CODE>[No Description Provided by Google]</CODE> 482 * <BR /> 483 * <BR /><B>EXPERIMENTAL</B> 484 */ 485 public static class DragData 486 extends BaseType 487 implements java.io.Serializable 488 { 489 /** For Object Serialization. java.io.Serializable */ 490 protected static final long serialVersionUID = 1; 491 492 public boolean[] optionals() 493 { return new boolean[] { false, true, false, }; } 494 495 /** <CODE>[No Description Provided by Google]</CODE> */ 496 public final Input.DragDataItem[] items; 497 498 /** 499 * List of filenames that should be included when dropping 500 * <BR /> 501 * <BR /><B>OPTIONAL</B> 502 */ 503 public final String[] files; 504 505 /** Bit field representing allowed drag operations. Copy = 1, Link = 2, Move = 16 */ 506 public final int dragOperationsMask; 507 508 /** 509 * Constructor 510 * 511 * @param items - 512 * 513 * @param files List of filenames that should be included when dropping 514 * <BR /><B>OPTIONAL</B> 515 * 516 * @param dragOperationsMask Bit field representing allowed drag operations. Copy = 1, Link = 2, Move = 16 517 */ 518 public DragData(Input.DragDataItem[] items, String[] files, int dragOperationsMask) 519 { 520 // Exception-Check(s) to ensure that if any parameters which are not declared as 521 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 522 523 if (items == null) BRDPC.throwNPE("items"); 524 525 this.items = items; 526 this.files = files; 527 this.dragOperationsMask = dragOperationsMask; 528 } 529 530 /** 531 * JSON Object Constructor 532 * @param jo A Json-Object having data about an instance of {@code 'DragData'}. 533 */ 534 public DragData (JsonObject jo) 535 { 536 this.items = (jo.getJsonArray("items") == null) 537 ? null 538 : RJArrDimN.objArr(jo.getJsonArray("items"), null, 0, Input.DragDataItem[].class); 539 540 this.files = (jo.getJsonArray("files") == null) 541 ? null 542 : RJArrIntoStream.strArr(jo.getJsonArray("files"), null, 0).toArray(String[]::new); 543 544 this.dragOperationsMask = ReadPrimJSON.getInt(jo, "dragOperationsMask"); 545 } 546 547 548 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 549 public boolean equals(Object other) 550 { 551 if (other == null) return false; 552 if (other.getClass() != this.getClass()) return false; 553 554 DragData o = (DragData) other; 555 556 return 557 Arrays.deepEquals(this.items, o.items) 558 && Arrays.deepEquals(this.files, o.files) 559 && (this.dragOperationsMask == o.dragOperationsMask); 560 } 561 562 /** Generates a Hash-Code for {@code 'this'} instance */ 563 public int hashCode() 564 { 565 return 566 Arrays.deepHashCode(this.items) 567 + Arrays.deepHashCode(this.files) 568 + this.dragOperationsMask; 569 } 570 } 571 572 /** 573 * Emitted only when <CODE>Input.setInterceptDrags</CODE> is enabled. Use this data with <CODE>Input.dispatchDragEvent</CODE> to 574 * restore normal drag and drop behavior. 575 * <BR /> 576 * <BR /><B>EXPERIMENTAL</B> 577 */ 578 public static class dragIntercepted 579 extends BrowserEvent 580 implements java.io.Serializable 581 { 582 /** For Object Serialization. java.io.Serializable */ 583 protected static final long serialVersionUID = 1; 584 585 public boolean[] optionals() 586 { return new boolean[] { false, }; } 587 588 /** <CODE>[No Description Provided by Google]</CODE> */ 589 public final Input.DragData data; 590 591 /** 592 * Constructor 593 * 594 * @param data - 595 */ 596 public dragIntercepted(Input.DragData data) 597 { 598 super("Input", "dragIntercepted", 1); 599 600 // Exception-Check(s) to ensure that if any parameters which are not declared as 601 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 602 603 if (data == null) BRDPC.throwNPE("data"); 604 605 this.data = data; 606 } 607 608 /** 609 * JSON Object Constructor 610 * @param jo A Json-Object having data about an instance of {@code 'dragIntercepted'}. 611 */ 612 public dragIntercepted (JsonObject jo) 613 { 614 super("Input", "dragIntercepted", 1); 615 616 this.data = ReadJSON.getObject(jo, "data", Input.DragData.class, false, true); 617 } 618 619 620 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 621 public boolean equals(Object other) 622 { 623 if (other == null) return false; 624 if (other.getClass() != this.getClass()) return false; 625 626 dragIntercepted o = (dragIntercepted) other; 627 628 return 629 Objects.equals(this.data, o.data); 630 } 631 632 /** Generates a Hash-Code for {@code 'this'} instance */ 633 public int hashCode() 634 { 635 return 636 this.data.hashCode(); 637 } 638 } 639 640 641 // Counter for keeping the WebSocket Request ID's distinct. 642 private static int counter = 1; 643 644 /** 645 * Dispatches a drag event into the page. 646 * <BR /><B>EXPERIMENTAL</B> 647 * 648 * @param type Type of the drag event. 649 * <BR />Acceptable Values: ["dragEnter", "dragOver", "drop", "dragCancel"] 650 * 651 * @param x X coordinate of the event relative to the main frame's viewport in CSS pixels. 652 * 653 * @param y 654 * Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to 655 * the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. 656 * 657 * @param data - 658 * 659 * @param modifiers 660 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 661 * (default: 0). 662 * <BR /><B>OPTIONAL</B> 663 * 664 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 665 * {@link Ret0}></CODE> 666 * 667 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 668 * browser receives the invocation-request. 669 * 670 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 671 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 672 * {@code >} to ensure the Browser Function has run to completion. 673 */ 674 public static Script<String, JsonObject, Ret0> dispatchDragEvent 675 (String type, Number x, Number y, Input.DragData data, Integer modifiers) 676 { 677 // Exception-Check(s) to ensure that if any parameters which are not declared as 678 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 679 680 if (type == null) BRDPC.throwNPE("type"); 681 if (x == null) BRDPC.throwNPE("x"); 682 if (y == null) BRDPC.throwNPE("y"); 683 if (data == null) BRDPC.throwNPE("data"); 684 685 // Exception-Check(s) to ensure that if any parameters which must adhere to a 686 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 687 688 BRDPC.checkIAE( 689 "type", type, 690 "dragEnter", "dragOver", "drop", "dragCancel" 691 ); 692 693 final int webSocketID = 25000000 + counter++; 694 final boolean[] optionals = { false, false, false, false, true, }; 695 696 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 697 String requestJSON = WriteJSON.get( 698 parameterTypes.get("dispatchDragEvent"), 699 parameterNames.get("dispatchDragEvent"), 700 optionals, webSocketID, 701 "Input.dispatchDragEvent", 702 type, x, y, data, modifiers 703 ); 704 705 // This Remote Command does not have a Return-Value. 706 return new Script<> 707 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 708 } 709 710 /** 711 * Dispatches a key event to the page. 712 * 713 * @param type Type of the key event. 714 * <BR />Acceptable Values: ["keyDown", "keyUp", "rawKeyDown", "char"] 715 * 716 * @param modifiers 717 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 718 * (default: 0). 719 * <BR /><B>OPTIONAL</B> 720 * 721 * @param timestamp Time at which the event occurred. 722 * <BR /><B>OPTIONAL</B> 723 * 724 * @param text 725 * Text as generated by processing a virtual key code with a keyboard layout. Not needed for 726 * for <CODE>keyUp</CODE> and <CODE>rawKeyDown</CODE> events (default: "") 727 * <BR /><B>OPTIONAL</B> 728 * 729 * @param unmodifiedText 730 * Text that would have been generated by the keyboard if no modifiers were pressed (except for 731 * shift). Useful for shortcut (accelerator) key handling (default: ""). 732 * <BR /><B>OPTIONAL</B> 733 * 734 * @param keyIdentifier Unique key identifier (e.g., 'U+0041') (default: ""). 735 * <BR /><B>OPTIONAL</B> 736 * 737 * @param code Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: ""). 738 * <BR /><B>OPTIONAL</B> 739 * 740 * @param key 741 * Unique DOM defined string value describing the meaning of the key in the context of active 742 * modifiers, keyboard layout, etc (e.g., 'AltGr') (default: ""). 743 * <BR /><B>OPTIONAL</B> 744 * 745 * @param windowsVirtualKeyCode Windows virtual key code (default: 0). 746 * <BR /><B>OPTIONAL</B> 747 * 748 * @param nativeVirtualKeyCode Native virtual key code (default: 0). 749 * <BR /><B>OPTIONAL</B> 750 * 751 * @param autoRepeat Whether the event was generated from auto repeat (default: false). 752 * <BR /><B>OPTIONAL</B> 753 * 754 * @param isKeypad Whether the event was generated from the keypad (default: false). 755 * <BR /><B>OPTIONAL</B> 756 * 757 * @param isSystemKey Whether the event was a system key event (default: false). 758 * <BR /><B>OPTIONAL</B> 759 * 760 * @param location 761 * Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default: 762 * 0). 763 * <BR /><B>OPTIONAL</B> 764 * 765 * @param commands 766 * Editing commands to send with the key event (e.g., 'selectAll') (default: []). 767 * These are related to but not equal the command names used in <CODE>document.execCommand</CODE> and NSStandardKeyBindingResponding. 768 * See https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names. 769 * <BR /><B>OPTIONAL</B> 770 * <BR /><B>EXPERIMENTAL</B> 771 * 772 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 773 * {@link Ret0}></CODE> 774 * 775 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 776 * browser receives the invocation-request. 777 * 778 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 779 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 780 * {@code >} to ensure the Browser Function has run to completion. 781 */ 782 public static Script<String, JsonObject, Ret0> dispatchKeyEvent( 783 String type, Integer modifiers, Number timestamp, String text, String unmodifiedText, 784 String keyIdentifier, String code, String key, Integer windowsVirtualKeyCode, 785 Integer nativeVirtualKeyCode, Boolean autoRepeat, Boolean isKeypad, Boolean isSystemKey, 786 Integer location, String[] commands 787 ) 788 { 789 // Exception-Check(s) to ensure that if any parameters which are not declared as 790 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 791 792 if (type == null) BRDPC.throwNPE("type"); 793 794 // Exception-Check(s) to ensure that if any parameters which must adhere to a 795 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 796 797 BRDPC.checkIAE( 798 "type", type, 799 "keyDown", "keyUp", "rawKeyDown", "char" 800 ); 801 802 final int webSocketID = 25001000 + counter++; 803 final boolean[] optionals = { false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, }; 804 805 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 806 String requestJSON = WriteJSON.get( 807 parameterTypes.get("dispatchKeyEvent"), 808 parameterNames.get("dispatchKeyEvent"), 809 optionals, webSocketID, 810 "Input.dispatchKeyEvent", 811 type, modifiers, timestamp, text, unmodifiedText, keyIdentifier, code, key, 812 windowsVirtualKeyCode, nativeVirtualKeyCode, autoRepeat, isKeypad, isSystemKey, 813 location, commands 814 ); 815 816 // This Remote Command does not have a Return-Value. 817 return new Script<> 818 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 819 } 820 821 /** 822 * This method emulates inserting text that doesn't come from a key press, 823 * for example an emoji keyboard or an IME. 824 * <BR /><B>EXPERIMENTAL</B> 825 * 826 * @param text The text to insert. 827 * 828 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 829 * {@link Ret0}></CODE> 830 * 831 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 832 * browser receives the invocation-request. 833 * 834 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 835 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 836 * {@code >} to ensure the Browser Function has run to completion. 837 */ 838 public static Script<String, JsonObject, Ret0> insertText(String text) 839 { 840 // Exception-Check(s) to ensure that if any parameters which are not declared as 841 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 842 843 if (text == null) BRDPC.throwNPE("text"); 844 845 final int webSocketID = 25002000 + counter++; 846 final boolean[] optionals = { false, }; 847 848 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 849 String requestJSON = WriteJSON.get( 850 parameterTypes.get("insertText"), 851 parameterNames.get("insertText"), 852 optionals, webSocketID, 853 "Input.insertText", 854 text 855 ); 856 857 // This Remote Command does not have a Return-Value. 858 return new Script<> 859 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 860 } 861 862 /** 863 * This method sets the current candidate text for ime. 864 * Use imeCommitComposition to commit the final text. 865 * Use imeSetComposition with empty string as text to cancel composition. 866 * <BR /><B>EXPERIMENTAL</B> 867 * 868 * @param text The text to insert 869 * 870 * @param selectionStart selection start 871 * 872 * @param selectionEnd selection end 873 * 874 * @param replacementStart replacement start 875 * <BR /><B>OPTIONAL</B> 876 * 877 * @param replacementEnd replacement end 878 * <BR /><B>OPTIONAL</B> 879 * 880 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 881 * {@link Ret0}></CODE> 882 * 883 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 884 * browser receives the invocation-request. 885 * 886 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 887 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 888 * {@code >} to ensure the Browser Function has run to completion. 889 */ 890 public static Script<String, JsonObject, Ret0> imeSetComposition( 891 String text, int selectionStart, int selectionEnd, Integer replacementStart, 892 Integer replacementEnd 893 ) 894 { 895 // Exception-Check(s) to ensure that if any parameters which are not declared as 896 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 897 898 if (text == null) BRDPC.throwNPE("text"); 899 900 final int webSocketID = 25003000 + counter++; 901 final boolean[] optionals = { false, false, false, true, true, }; 902 903 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 904 String requestJSON = WriteJSON.get( 905 parameterTypes.get("imeSetComposition"), 906 parameterNames.get("imeSetComposition"), 907 optionals, webSocketID, 908 "Input.imeSetComposition", 909 text, selectionStart, selectionEnd, replacementStart, replacementEnd 910 ); 911 912 // This Remote Command does not have a Return-Value. 913 return new Script<> 914 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 915 } 916 917 /** 918 * Dispatches a mouse event to the page. 919 * 920 * @param type Type of the mouse event. 921 * <BR />Acceptable Values: ["mousePressed", "mouseReleased", "mouseMoved", "mouseWheel"] 922 * 923 * @param x X coordinate of the event relative to the main frame's viewport in CSS pixels. 924 * 925 * @param y 926 * Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to 927 * the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. 928 * 929 * @param modifiers 930 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 931 * (default: 0). 932 * <BR /><B>OPTIONAL</B> 933 * 934 * @param timestamp Time at which the event occurred. 935 * <BR /><B>OPTIONAL</B> 936 * 937 * @param button Mouse button (default: "none"). 938 * <BR /><B>OPTIONAL</B> 939 * 940 * @param buttons 941 * A number indicating which buttons are pressed on the mouse when a mouse event is triggered. 942 * Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0. 943 * <BR /><B>OPTIONAL</B> 944 * 945 * @param clickCount Number of times the mouse button was clicked (default: 0). 946 * <BR /><B>OPTIONAL</B> 947 * 948 * @param force The normalized pressure, which has a range of [0,1] (default: 0). 949 * <BR /><B>OPTIONAL</B> 950 * <BR /><B>EXPERIMENTAL</B> 951 * 952 * @param tangentialPressure The normalized tangential pressure, which has a range of [-1,1] (default: 0). 953 * <BR /><B>OPTIONAL</B> 954 * <BR /><B>EXPERIMENTAL</B> 955 * 956 * @param tiltX The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0). 957 * <BR /><B>OPTIONAL</B> 958 * <BR /><B>EXPERIMENTAL</B> 959 * 960 * @param tiltY The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0). 961 * <BR /><B>OPTIONAL</B> 962 * <BR /><B>EXPERIMENTAL</B> 963 * 964 * @param twist The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0). 965 * <BR /><B>OPTIONAL</B> 966 * <BR /><B>EXPERIMENTAL</B> 967 * 968 * @param deltaX X delta in CSS pixels for mouse wheel event (default: 0). 969 * <BR /><B>OPTIONAL</B> 970 * 971 * @param deltaY Y delta in CSS pixels for mouse wheel event (default: 0). 972 * <BR /><B>OPTIONAL</B> 973 * 974 * @param pointerType Pointer type (default: "mouse"). 975 * <BR />Acceptable Values: ["mouse", "pen"] 976 * <BR /><B>OPTIONAL</B> 977 * 978 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 979 * {@link Ret0}></CODE> 980 * 981 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 982 * browser receives the invocation-request. 983 * 984 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 985 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 986 * {@code >} to ensure the Browser Function has run to completion. 987 */ 988 public static Script<String, JsonObject, Ret0> dispatchMouseEvent( 989 String type, Number x, Number y, Integer modifiers, Number timestamp, String button, 990 Integer buttons, Integer clickCount, Number force, Number tangentialPressure, 991 Integer tiltX, Integer tiltY, Integer twist, Number deltaX, Number deltaY, 992 String pointerType 993 ) 994 { 995 // Exception-Check(s) to ensure that if any parameters which are not declared as 996 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 997 998 if (type == null) BRDPC.throwNPE("type"); 999 if (x == null) BRDPC.throwNPE("x"); 1000 if (y == null) BRDPC.throwNPE("y"); 1001 1002 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1003 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1004 1005 BRDPC.checkIAE( 1006 "type", type, 1007 "mousePressed", "mouseReleased", "mouseMoved", "mouseWheel" 1008 ); 1009 BRDPC.checkIAE("button", button, "Input.MouseButton", Input.MouseButton); 1010 BRDPC.checkIAE( 1011 "pointerType", pointerType, 1012 "mouse", "pen" 1013 ); 1014 1015 final int webSocketID = 25004000 + counter++; 1016 final boolean[] optionals = { false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, }; 1017 1018 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1019 String requestJSON = WriteJSON.get( 1020 parameterTypes.get("dispatchMouseEvent"), 1021 parameterNames.get("dispatchMouseEvent"), 1022 optionals, webSocketID, 1023 "Input.dispatchMouseEvent", 1024 type, x, y, modifiers, timestamp, button, buttons, clickCount, force, 1025 tangentialPressure, tiltX, tiltY, twist, deltaX, deltaY, pointerType 1026 ); 1027 1028 // This Remote Command does not have a Return-Value. 1029 return new Script<> 1030 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 1031 } 1032 1033 /** 1034 * Dispatches a touch event to the page. 1035 * 1036 * @param type 1037 * Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while 1038 * TouchStart and TouchMove must contains at least one. 1039 * <BR />Acceptable Values: ["touchStart", "touchEnd", "touchMove", "touchCancel"] 1040 * 1041 * @param touchPoints 1042 * Active touch points on the touch device. One event per any changed point (compared to 1043 * previous touch event in a sequence) is generated, emulating pressing/moving/releasing points 1044 * one by one. 1045 * 1046 * @param modifiers 1047 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 1048 * (default: 0). 1049 * <BR /><B>OPTIONAL</B> 1050 * 1051 * @param timestamp Time at which the event occurred. 1052 * <BR /><B>OPTIONAL</B> 1053 * 1054 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1055 * {@link Ret0}></CODE> 1056 * 1057 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1058 * browser receives the invocation-request. 1059 * 1060 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1061 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1062 * {@code >} to ensure the Browser Function has run to completion. 1063 */ 1064 public static Script<String, JsonObject, Ret0> dispatchTouchEvent 1065 (String type, Input.TouchPoint[] touchPoints, Integer modifiers, Number timestamp) 1066 { 1067 // Exception-Check(s) to ensure that if any parameters which are not declared as 1068 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1069 1070 if (type == null) BRDPC.throwNPE("type"); 1071 if (touchPoints == null) BRDPC.throwNPE("touchPoints"); 1072 1073 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1074 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1075 1076 BRDPC.checkIAE( 1077 "type", type, 1078 "touchStart", "touchEnd", "touchMove", "touchCancel" 1079 ); 1080 1081 final int webSocketID = 25005000 + counter++; 1082 final boolean[] optionals = { false, false, true, true, }; 1083 1084 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1085 String requestJSON = WriteJSON.get( 1086 parameterTypes.get("dispatchTouchEvent"), 1087 parameterNames.get("dispatchTouchEvent"), 1088 optionals, webSocketID, 1089 "Input.dispatchTouchEvent", 1090 type, touchPoints, modifiers, timestamp 1091 ); 1092 1093 // This Remote Command does not have a Return-Value. 1094 return new Script<> 1095 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 1096 } 1097 1098 /** 1099 * Emulates touch event from the mouse event parameters. 1100 * <BR /><B>EXPERIMENTAL</B> 1101 * 1102 * @param type Type of the mouse event. 1103 * <BR />Acceptable Values: ["mousePressed", "mouseReleased", "mouseMoved", "mouseWheel"] 1104 * 1105 * @param x X coordinate of the mouse pointer in DIP. 1106 * 1107 * @param y Y coordinate of the mouse pointer in DIP. 1108 * 1109 * @param button Mouse button. Only "none", "left", "right" are supported. 1110 * 1111 * @param timestamp Time at which the event occurred (default: current time). 1112 * <BR /><B>OPTIONAL</B> 1113 * 1114 * @param deltaX X delta in DIP for mouse wheel event (default: 0). 1115 * <BR /><B>OPTIONAL</B> 1116 * 1117 * @param deltaY Y delta in DIP for mouse wheel event (default: 0). 1118 * <BR /><B>OPTIONAL</B> 1119 * 1120 * @param modifiers 1121 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 1122 * (default: 0). 1123 * <BR /><B>OPTIONAL</B> 1124 * 1125 * @param clickCount Number of times the mouse button was clicked (default: 0). 1126 * <BR /><B>OPTIONAL</B> 1127 * 1128 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1129 * {@link Ret0}></CODE> 1130 * 1131 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1132 * browser receives the invocation-request. 1133 * 1134 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1135 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1136 * {@code >} to ensure the Browser Function has run to completion. 1137 */ 1138 public static Script<String, JsonObject, Ret0> emulateTouchFromMouseEvent( 1139 String type, int x, int y, String button, Number timestamp, Number deltaX, 1140 Number deltaY, Integer modifiers, Integer clickCount 1141 ) 1142 { 1143 // Exception-Check(s) to ensure that if any parameters which are not declared as 1144 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1145 1146 if (type == null) BRDPC.throwNPE("type"); 1147 if (button == null) BRDPC.throwNPE("button"); 1148 1149 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1150 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1151 1152 BRDPC.checkIAE( 1153 "type", type, 1154 "mousePressed", "mouseReleased", "mouseMoved", "mouseWheel" 1155 ); 1156 BRDPC.checkIAE("button", button, "Input.MouseButton", Input.MouseButton); 1157 1158 final int webSocketID = 25006000 + counter++; 1159 final boolean[] optionals = { false, false, false, false, true, true, true, true, true, }; 1160 1161 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1162 String requestJSON = WriteJSON.get( 1163 parameterTypes.get("emulateTouchFromMouseEvent"), 1164 parameterNames.get("emulateTouchFromMouseEvent"), 1165 optionals, webSocketID, 1166 "Input.emulateTouchFromMouseEvent", 1167 type, x, y, button, timestamp, deltaX, deltaY, modifiers, clickCount 1168 ); 1169 1170 // This Remote Command does not have a Return-Value. 1171 return new Script<> 1172 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 1173 } 1174 1175 /** 1176 * Ignores input events (useful while auditing page). 1177 * 1178 * @param ignore Ignores input events processing when set to true. 1179 * 1180 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1181 * {@link Ret0}></CODE> 1182 * 1183 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1184 * browser receives the invocation-request. 1185 * 1186 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1187 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1188 * {@code >} to ensure the Browser Function has run to completion. 1189 */ 1190 public static Script<String, JsonObject, Ret0> setIgnoreInputEvents(boolean ignore) 1191 { 1192 final int webSocketID = 25007000 + counter++; 1193 final boolean[] optionals = { false, }; 1194 1195 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1196 String requestJSON = WriteJSON.get( 1197 parameterTypes.get("setIgnoreInputEvents"), 1198 parameterNames.get("setIgnoreInputEvents"), 1199 optionals, webSocketID, 1200 "Input.setIgnoreInputEvents", 1201 ignore 1202 ); 1203 1204 // This Remote Command does not have a Return-Value. 1205 return new Script<> 1206 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 1207 } 1208 1209 /** 1210 * Prevents default drag and drop behavior and instead emits <CODE>Input.dragIntercepted</CODE> events. 1211 * Drag and drop behavior can be directly controlled via <CODE>Input.dispatchDragEvent</CODE>. 1212 * <BR /><B>EXPERIMENTAL</B> 1213 * 1214 * @param enabled - 1215 * 1216 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1217 * {@link Ret0}></CODE> 1218 * 1219 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1220 * browser receives the invocation-request. 1221 * 1222 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1223 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1224 * {@code >} to ensure the Browser Function has run to completion. 1225 */ 1226 public static Script<String, JsonObject, Ret0> setInterceptDrags(boolean enabled) 1227 { 1228 final int webSocketID = 25008000 + counter++; 1229 final boolean[] optionals = { false, }; 1230 1231 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1232 String requestJSON = WriteJSON.get( 1233 parameterTypes.get("setInterceptDrags"), 1234 parameterNames.get("setInterceptDrags"), 1235 optionals, webSocketID, 1236 "Input.setInterceptDrags", 1237 enabled 1238 ); 1239 1240 // This Remote Command does not have a Return-Value. 1241 return new Script<> 1242 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 1243 } 1244 1245 /** 1246 * Synthesizes a pinch gesture over a time period by issuing appropriate touch events. 1247 * <BR /><B>EXPERIMENTAL</B> 1248 * 1249 * @param x X coordinate of the start of the gesture in CSS pixels. 1250 * 1251 * @param y Y coordinate of the start of the gesture in CSS pixels. 1252 * 1253 * @param scaleFactor Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out). 1254 * 1255 * @param relativeSpeed Relative pointer speed in pixels per second (default: 800). 1256 * <BR /><B>OPTIONAL</B> 1257 * 1258 * @param gestureSourceType 1259 * Which type of input events to be generated (default: 'default', which queries the platform 1260 * for the preferred input type). 1261 * <BR /><B>OPTIONAL</B> 1262 * 1263 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1264 * {@link Ret0}></CODE> 1265 * 1266 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1267 * browser receives the invocation-request. 1268 * 1269 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1270 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1271 * {@code >} to ensure the Browser Function has run to completion. 1272 */ 1273 public static Script<String, JsonObject, Ret0> synthesizePinchGesture 1274 (Number x, Number y, Number scaleFactor, Integer relativeSpeed, String gestureSourceType) 1275 { 1276 // Exception-Check(s) to ensure that if any parameters which are not declared as 1277 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1278 1279 if (x == null) BRDPC.throwNPE("x"); 1280 if (y == null) BRDPC.throwNPE("y"); 1281 if (scaleFactor == null) BRDPC.throwNPE("scaleFactor"); 1282 1283 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1284 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1285 1286 BRDPC.checkIAE("gestureSourceType", gestureSourceType, "Input.GestureSourceType", Input.GestureSourceType); 1287 1288 final int webSocketID = 25009000 + counter++; 1289 final boolean[] optionals = { false, false, false, true, true, }; 1290 1291 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1292 String requestJSON = WriteJSON.get( 1293 parameterTypes.get("synthesizePinchGesture"), 1294 parameterNames.get("synthesizePinchGesture"), 1295 optionals, webSocketID, 1296 "Input.synthesizePinchGesture", 1297 x, y, scaleFactor, relativeSpeed, gestureSourceType 1298 ); 1299 1300 // This Remote Command does not have a Return-Value. 1301 return new Script<> 1302 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 1303 } 1304 1305 /** 1306 * Synthesizes a scroll gesture over a time period by issuing appropriate touch events. 1307 * <BR /><B>EXPERIMENTAL</B> 1308 * 1309 * @param x X coordinate of the start of the gesture in CSS pixels. 1310 * 1311 * @param y Y coordinate of the start of the gesture in CSS pixels. 1312 * 1313 * @param xDistance The distance to scroll along the X axis (positive to scroll left). 1314 * <BR /><B>OPTIONAL</B> 1315 * 1316 * @param yDistance The distance to scroll along the Y axis (positive to scroll up). 1317 * <BR /><B>OPTIONAL</B> 1318 * 1319 * @param xOverscroll 1320 * The number of additional pixels to scroll back along the X axis, in addition to the given 1321 * distance. 1322 * <BR /><B>OPTIONAL</B> 1323 * 1324 * @param yOverscroll 1325 * The number of additional pixels to scroll back along the Y axis, in addition to the given 1326 * distance. 1327 * <BR /><B>OPTIONAL</B> 1328 * 1329 * @param preventFling Prevent fling (default: true). 1330 * <BR /><B>OPTIONAL</B> 1331 * 1332 * @param speed Swipe speed in pixels per second (default: 800). 1333 * <BR /><B>OPTIONAL</B> 1334 * 1335 * @param gestureSourceType 1336 * Which type of input events to be generated (default: 'default', which queries the platform 1337 * for the preferred input type). 1338 * <BR /><B>OPTIONAL</B> 1339 * 1340 * @param repeatCount The number of times to repeat the gesture (default: 0). 1341 * <BR /><B>OPTIONAL</B> 1342 * 1343 * @param repeatDelayMs The number of milliseconds delay between each repeat. (default: 250). 1344 * <BR /><B>OPTIONAL</B> 1345 * 1346 * @param interactionMarkerName The name of the interaction markers to generate, if not empty (default: ""). 1347 * <BR /><B>OPTIONAL</B> 1348 * 1349 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1350 * {@link Ret0}></CODE> 1351 * 1352 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1353 * browser receives the invocation-request. 1354 * 1355 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1356 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1357 * {@code >} to ensure the Browser Function has run to completion. 1358 */ 1359 public static Script<String, JsonObject, Ret0> synthesizeScrollGesture( 1360 Number x, Number y, Number xDistance, Number yDistance, Number xOverscroll, 1361 Number yOverscroll, Boolean preventFling, Integer speed, String gestureSourceType, 1362 Integer repeatCount, Integer repeatDelayMs, String interactionMarkerName 1363 ) 1364 { 1365 // Exception-Check(s) to ensure that if any parameters which are not declared as 1366 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1367 1368 if (x == null) BRDPC.throwNPE("x"); 1369 if (y == null) BRDPC.throwNPE("y"); 1370 1371 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1372 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1373 1374 BRDPC.checkIAE("gestureSourceType", gestureSourceType, "Input.GestureSourceType", Input.GestureSourceType); 1375 1376 final int webSocketID = 25010000 + counter++; 1377 final boolean[] optionals = { false, false, true, true, true, true, true, true, true, true, true, true, }; 1378 1379 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1380 String requestJSON = WriteJSON.get( 1381 parameterTypes.get("synthesizeScrollGesture"), 1382 parameterNames.get("synthesizeScrollGesture"), 1383 optionals, webSocketID, 1384 "Input.synthesizeScrollGesture", 1385 x, y, xDistance, yDistance, xOverscroll, yOverscroll, preventFling, speed, 1386 gestureSourceType, repeatCount, repeatDelayMs, interactionMarkerName 1387 ); 1388 1389 // This Remote Command does not have a Return-Value. 1390 return new Script<> 1391 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 1392 } 1393 1394 /** 1395 * Synthesizes a tap gesture over a time period by issuing appropriate touch events. 1396 * <BR /><B>EXPERIMENTAL</B> 1397 * 1398 * @param x X coordinate of the start of the gesture in CSS pixels. 1399 * 1400 * @param y Y coordinate of the start of the gesture in CSS pixels. 1401 * 1402 * @param duration Duration between touchdown and touchup events in ms (default: 50). 1403 * <BR /><B>OPTIONAL</B> 1404 * 1405 * @param tapCount Number of times to perform the tap (e.g. 2 for double tap, default: 1). 1406 * <BR /><B>OPTIONAL</B> 1407 * 1408 * @param gestureSourceType 1409 * Which type of input events to be generated (default: 'default', which queries the platform 1410 * for the preferred input type). 1411 * <BR /><B>OPTIONAL</B> 1412 * 1413 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1414 * {@link Ret0}></CODE> 1415 * 1416 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1417 * browser receives the invocation-request. 1418 * 1419 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1420 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1421 * {@code >} to ensure the Browser Function has run to completion. 1422 */ 1423 public static Script<String, JsonObject, Ret0> synthesizeTapGesture 1424 (Number x, Number y, Integer duration, Integer tapCount, String gestureSourceType) 1425 { 1426 // Exception-Check(s) to ensure that if any parameters which are not declared as 1427 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1428 1429 if (x == null) BRDPC.throwNPE("x"); 1430 if (y == null) BRDPC.throwNPE("y"); 1431 1432 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1433 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1434 1435 BRDPC.checkIAE("gestureSourceType", gestureSourceType, "Input.GestureSourceType", Input.GestureSourceType); 1436 1437 final int webSocketID = 25011000 + counter++; 1438 final boolean[] optionals = { false, false, true, true, true, }; 1439 1440 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1441 String requestJSON = WriteJSON.get( 1442 parameterTypes.get("synthesizeTapGesture"), 1443 parameterNames.get("synthesizeTapGesture"), 1444 optionals, webSocketID, 1445 "Input.synthesizeTapGesture", 1446 x, y, duration, tapCount, gestureSourceType 1447 ); 1448 1449 // This Remote Command does not have a Return-Value. 1450 return new Script<> 1451 (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); 1452 } 1453 1454}