Convert a screen space position to native UI position * @param {Vector2} pos * @return {Vector2}
(pos)
| 477 | * @param {Vector2} pos |
| 478 | * @return {Vector2} */ |
| 479 | screenToNative(pos) |
| 480 | { |
| 481 | if (!uiSystem.nativeHeight) |
| 482 | return pos; |
| 483 | |
| 484 | const s = mainCanvasSize.y / uiSystem.nativeHeight; |
| 485 | const sInv = 1/s; |
| 486 | const p = pos.copy(); |
| 487 | p.x += s*mainCanvasSize.x/2; |
| 488 | p.x *= sInv; |
| 489 | p.y *= sInv; |
| 490 | p.x -= sInv*mainCanvasSize.x/2; |
| 491 | return p; |
| 492 | } |
| 493 | |
| 494 | /** Object to send keyboard input to (typically a UITextInput). |
| 495 | * The document keydown listener is only attached while this is set, |
no test coverage detected