Showing the changes to libraries/script-engine/src/ScriptManagerScriptingInterface.h (1 of 3 files). Show all
Unified · Split
| @@ -298,26 +298,26 @@ public: · 297 unmodified lines | |||
| 298 | * @function Script.setInterval | 298 | * @function Script.setInterval |
| 299 | * @param {function} function - The function to call. This can be either the name of a function or an in-line definition. | 299 | * @param {function} function - The function to call. This can be either the name of a function or an in-line definition. |
| 300 | * @param {number} interval - The interval at which to call the function, in ms. | 300 | * @param {number} interval - The interval at which to call the function, in ms. |
| 301 | * @returns {object} A handle to the interval timer. This can be used in {@link Script.clearInterval}. | 301 | * @returns {number} A handle to the interval timer. This can be used in {@link Script.clearInterval}. |
| 302 | * @example <caption>Print a message every second.</caption> | 302 | * @example <caption>Print a message every second.</caption> |
| 303 | * Script.setInterval(function () { | 303 | * Script.setInterval(function () { |
| 304 | * print("Interval timer fired"); | 304 | * print("Interval timer fired"); |
| 305 | * }, 1000); | 305 | * }, 1000); |
| 306 | */ | 306 | */ |
| 307 | Q_INVOKABLE QTimer* setInterval(const ScriptValue& function, int intervalMS) { return _manager->setInterval(function, intervalMS); } | 307 | Q_INVOKABLE int setInterval(const ScriptValue& function, int intervalMS) { return _manager->setInterval(function, intervalMS); } |
| 308 | 308 | ||
| 309 | /*@jsdoc | 309 | /*@jsdoc |
| 310 | * Calls a function once, after a delay. | 310 | * Calls a function once, after a delay. |
| 311 | * @function Script.setTimeout | 311 | * @function Script.setTimeout |
| 312 | * @param {function} function - The function to call. This can be either the name of a function or an in-line definition. | 312 | * @param {function} function - The function to call. This can be either the name of a function or an in-line definition. |
| 313 | * @param {number} timeout - The delay after which to call the function, in ms. | 313 | * @param {number} timeout - The delay after which to call the function, in ms. |
| 314 | * @returns {object} A handle to the timeout timer. This can be used in {@link Script.clearTimeout}. | 314 | * @returns {number} A handle to the timeout timer. This can be used in {@link Script.clearTimeout}. |
| 315 | * @example <caption>Print a message once, after a second.</caption> | 315 | * @example <caption>Print a message once, after a second.</caption> |
| 316 | * Script.setTimeout(function () { | 316 | * Script.setTimeout(function () { |
| 317 | * print("Timeout timer fired"); | 317 | * print("Timeout timer fired"); |
| 318 | * }, 1000); | 318 | * }, 1000); |
| 319 | */ | 319 | */ |
| 320 | Q_INVOKABLE QTimer* setTimeout(const ScriptValue& function, int timeoutMS) { return _manager->setTimeout(function, timeoutMS); }; | 320 | Q_INVOKABLE int setTimeout(const ScriptValue& function, int timeoutMS) { return _manager->setTimeout(function, timeoutMS); }; |
| 321 | 321 | ||
| 322 | /*@jsdoc | 322 | /*@jsdoc |
| 323 | * Stops an interval timer set by {@link Script.setInterval|setInterval}. | 323 | * Stops an interval timer set by {@link Script.setInterval|setInterval}. |
| @@ -335,10 +335,7 @@ public: · 11 unmodified lines | |||
| 335 | * Script.clearInterval(timer); | 335 | * Script.clearInterval(timer); |
| 336 | * }, 10000); | 336 | * }, 10000); |
| 337 | */ | 337 | */ |
| 338 | Q_INVOKABLE void clearInterval(QTimer* timer) { _manager->clearInterval(timer); } | 338 | Q_INVOKABLE void clearInterval(int timer) { _manager->clearInterval(timer); } |
| 339 | |||
| 340 | // Overloaded version is needed in case the timer has expired | ||
| 341 | Q_INVOKABLE void clearInterval(QVariantMap timer) { ; } | ||
| 342 | 339 | ||
| 343 | /*@jsdoc | 340 | /*@jsdoc |
| 344 | * Stops a timeout timer set by {@link Script.setTimeout|setTimeout}. | 341 | * Stops a timeout timer set by {@link Script.setTimeout|setTimeout}. |
| @@ -353,10 +350,7 @@ public: · 8 unmodified lines | |||
| 353 | * // Uncomment the following line to stop the timer from firing. | 350 | * // Uncomment the following line to stop the timer from firing. |
| 354 | * //Script.clearTimeout(timer); | 351 | * //Script.clearTimeout(timer); |
| 355 | */ | 352 | */ |
| 356 | Q_INVOKABLE void clearTimeout(QTimer* timer) { _manager->clearTimeout(timer); } | 353 | Q_INVOKABLE void clearTimeout(int timer) { _manager->clearTimeout(timer); } |
| 357 | |||
| 358 | // Overloaded version is needed in case the timer has expired | ||
| 359 | Q_INVOKABLE void clearTimeout(QVariantMap timer) { ; } | ||
| 360 | 354 | ||
| 361 | /*@jsdoc | 355 | /*@jsdoc |
| 362 | * Prints a message to the program log and emits {@link Script.printedMessage}. | 356 | * Prints a message to the program log and emits {@link Script.printedMessage}. |