PP.Ui.toImage(element: PP.Ui.Control, callback: PP.Delegate | Function, bounds: PP.Rect);
element. Item control.
callback. Callback function which is executed after image drawing. The Canvas argument is an area with the image.
bounds. Borders of the area to render.
The toImage method screenshots the item area.
To execute the example, the HTML page must contain links to PP.js, PP.Util.js script files and to PP.css styles file, in the <body> tag of the HTML page of the <div> items with the button identifier. In the onload event of the <body> tag it is necessary to specify the call of the createButton() function. Add the button on the page:
var button; function createButton() { // Create a button button = new PP.Ui.Button({ // Set parent item ParentNode: document.getElementById("button"), // Set button contents Content: "Button", });
Display the button snapshot under the button item:
var domNode = button.getDomNode(); // Get button control var ctrlButton = PP.Ui.getCtrlById(domNode.id); // Get button snapshot and display it under the button PP.Ui.toImage(ctrlButton, function (sender, args) { domNode.insertAdjacentElement("afterEnd", args.Canvas) });
As a result, the button snapshot is displayed under the button:
See also: