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:

Parameters:

Name Type Description

xOrPoint

number | Object

Either the X coordinate or a point object containing {x, y}.

[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:

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