Global Variables
Novadesk injects several globals into scripts. Some are available in both Main and UI scripts, while others are context-specific.
Table of Contents
__dirname
- Type:
string - Available in: Main script, UI script
Absolute directory path of the current script file.
Example
console.log(__dirname);__filename
- Type:
string - Available in: Main script, UI script
Absolute path to the current script file.
Example
console.log(__filename);__widgetDir
- Type:
string - Available in: Main script, UI script
Absolute path to the Widgets root directory.
Example
console.log(__widgetDir);__addonsPath
- Type:
string - Available in: Main script, UI script
Absolute path to the Addons directory.
Example
console.log(__addonsPath);__mainScriptDirPath
- Type:
string - Available in: Main script, UI script
Absolute directory path of the entry/main script file.
This is useful in UI scripts when you need to resolve assets relative to the main script location.
Example
console.log(__mainScriptDirPath);Mouse Event Object
Widget callbacks and element mouse handlers receive an event object with:
__clientX, __clientY
- Type:
number
Mouse coordinates in widget client space.
__screenX, __screenY
- Type:
number
Mouse coordinates in screen space.
__offsetX, __offsetY
- Type:
number
Offset relative to the target region.
__offsetXPercent, __offsetYPercent
- Type:
number - Range: Usually
0to100; may be outside this range duringmouseLeave.
Percentage offsets within the target region.
Example
import { widgetWindow } from "novadesk";
const win = new widgetWindow({
id: "demo",
width: 300,
height: 200,
script: "ui.js",
backgroundColor: "rgb(10,10,10)"
});
win.on("mouseMove", (e) => {
console.log("client:", e.__clientX, e.__clientY);
console.log("screen:", e.__screenX, e.__screenY);
console.log("offset:", e.__offsetX, e.__offsetY);
});INFO
Mouse event fields are exposed as underscored properties (for example __clientX, __offsetYPercent).