Ion.util
Collection of utility functions.
Available since: 1.0
Methods
Open a URL in its default handler program, as decided by the operating system. E.g.:
- http: => Web Browser
- mailto: => Mail Client
- file: => Default Program for the File's Type
// Compose a new email message with a subject of "Greetings Earthling!"
Ion.util.openUrl('mailto:?subject=Greetings%20Earthling!');
Available since: 1.0
Returns
- Boolean
trueif the URL was successfully opened,falseif not.
Capture all or a portion of the application window and save as a png file.
var path = Ion.io.userDocsPath + 'screenshot.png';
// Capture the entire window.
Ion.util.takeScreenshot(path);
// Capture the part of the window to the right of and below (15, 25)
Ion.util.takeScreenshot(path, {x: 15, y: 25});
// Capture a 100 x 200 portion of the window starting at (0, 0)
Ion.util.takeScreenshot(path, {width: 100, height: 200});
// Capture a 100 x 200 portion of the window starting at (50, 50)
Ion.util.takeScreenshot(path, {x: 50, y: 50, width: 100, height: 200});
Available since: Desktop Packager 1.1
Parameters
- filePath : String
Path to the file where the screenshot should be saved. If any directories in
filePathare missing, they will be created.filePathwill be canonicalized (seeIon.io.canonicalizePath()) - options : Object (optional)
Object containing the following options:
- x : Number (optional)
The x offset of the window rectangle to capture. Defaults to 0 (zero).
- y : Number (optional)
The y offset of the window rectangle to capture. Defaults to 0 (zero).
- width : Number (optional)
The width of the window rectangle to capture. Defaults to window width - x.
- height : Number (optional)
The height of the window rectangle to capture. Defaults to window height - y.
Note that if only
xand / oryare specified, the entire screen to the right and belowx, ywill be captured. If no position or size is specified, the entire window will be captured.
- x : Number (optional)
Returns
- Boolean
trueif the screen shot is successfully captured tofilePath.