calculateMouseCoords(event);
event. Mouse event.
The calculateMouseCoords method calculates current coordinates of the mouse cursor.
This method returns a JSON object with the following fields: X - abscissa, Y - ordinate of the current mouse cursor position.
To execute the example, the HTML page must contain links to the PP.js scenario file and the PP.css styles file. Create a text area, process event of clicking on this area and show current coordinates of the mouse cursor in the area:
// Create a text area var textArea = new PP.Ui.TextArea({ ParentNode: document.body, Width: 250, Height: 100, }); // Process the Click event textArea.Click.add(function (sender, args) { if (PP.isDownOn(textArea.getDomNode(), args.Event)) { // Determine the current mouse coordinates if the cursor is above the text area var coord = PP.calculateMouseCoords(args.Event); textArea.setContent("Current mouse coordinates: (" + coord.X + ", " + coord.Y + ")"); }; });
After executing the example a text area is created and placed in the page. On clicking this area the area shows current cursor coordinated:
See also: