screenIndexAt(xOrPoint, [y])
Class: SwingUI.
Description:
Returns the index of the screen whose bounds contain the given coordinate, or -1 if the point does not fall within any configured screen.
Accepts either:
- Separate numeric coordinates (x, y), or
- A point-like object with numeric
xandyproperties.
Parameters:
| Name | Type | Description |
|---|---|---|
|
|
number | Object |
Either the X coordinate or a point object containing {x, y}. |
|
|
number |
The Y coordinate (required if xOrPoint is a number). |
Returns:
The index of the matching screen, or -1 if none matched.
Type: number
Throws:
- Error: If the input is invalid (object is missing
x or y properties) or coordinates are not finite numbers.Examples:
Using separate x and y coordinates
const screenIndex = ui.screenIndexAt(1920, 540);
console.log(screenIndex); // e.g. 1, or -1 if not within any screen
Using a point object
const cursor = { x: 3440, y: 1080 };
const screenIndex = ui.screenIndexAt(cursor);
console.log(screenIndex); // e.g. 2, or -1 if not within any screen
