Home > PCB_SelectControl > getCurrentMousePosition
PCB_SelectControl.getCurrentMousePosition() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Get Current the mouse position on the canvas
Signature
typescript
function getCurrentMousePosition(): Promise<{ x: number; y: number } | undefined>;1
Returns
Promise<{ x: number; y: number } | undefined>
The mouse position on the canvas. undefined means the current mouse is not on the canvas
Example
javascript
// 1. 查询鼠标当前位置
const position = await eda.pcb_SelectControl.getCurrentMousePosition();
// 2. 鼠标在画布上时输出坐标,不在画布上时返回 undefined
if (position) {
console.log('x:', position.x);
console.log('y:', position.y);
}
else {
console.log('鼠标当前不在画布上');
}1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11