1# Window 2 3The `Window` module provides basic window management capabilities, such as creating and destroying the current window and setting properties for the current window. 4 5This module provides the following common window-related functions: 6 7[Window](#window): the current window instance, which is the basic unit managed by the window manager. 8 9> **NOTE** 10> 11> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. 12 13 14## Modules to Import 15 16```js 17import window from '@ohos.window'; 18``` 19 20## WindowType<sup>7+</sup> 21 22Enumerates the window types. 23 24**System capability**: SystemCapability.WindowManager.WindowManager.Core 25 26| Name | Value| Description | 27| ----------------- | ------ | ------------------ | 28| TYPE_APP | 0 | Application subwindow.| 29| TYPE_SYSTEM_ALERT | 1 | System alert window.| 30 31 32## AvoidAreaType<sup>7+</sup> 33 34Enumerates the types of the area where the window cannot be displayed. 35 36**System capability**: SystemCapability.WindowManager.WindowManager.Core 37 38| Name | Value | Description | 39| ----------- | ---- | ------------------ | 40| TYPE_SYSTEM | 0 | Default area of the system.| 41| TYPE_CUTOUT | 1 | Notch. | 42 43## WindowMode<sup>7+</sup> 44 45Enumerates the window modes. 46 47**System API**: This is a system API and cannot be called by third-party applications. 48 49**System capability**: SystemCapability.WindowManager.WindowManager.Core 50 51| Name | Value | Description | 52| ---------- | ---- | ----------------------------- | 53| UNDEFINED | 1 | The window mode is not defined by the application. | 54| FULLSCREEN | 2 | The application is displayed in full screen. | 55| PRIMARY | 3 | The application is displayed in the primary window in split-screen mode. | 56| SECONDARY | 4 | The application is displayed in the secondary window in split-screen mode. | 57| FLOATING | 5 | The application is displayed in a floating window.| 58 59## SystemBarProperties 60 61Describes the properties of the status bar and navigation bar. 62 63**System capability**: SystemCapability.WindowManager.WindowManager.Core 64 65| Name | Type| Readable| Writable| Description | 66| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | 67| statusBarColor | string | No | Yes | Background color of the status bar. The value is a hexadecimal RGB or ARGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`. | 68| isStatusBarLightIcon<sup>7+</sup> | boolean | No | Yes | Whether any icon on the status bar is highlighted. | 69| statusBarContentColor<sup>8+</sup> | string | No | Yes | Color of the text on the status bar. | 70| navigationBarColor | string | No | Yes | Background color of the navigation bar. The value is a hexadecimal RGB or ARGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`. | 71| isNavigationBarLightIcon<sup>7+</sup> | boolean | No | Yes | Whether any icon on the navigation bar is highlighted. | 72| navigationBarContentColor<sup>8+</sup> | string | No | Yes | Color of the text on the navigation bar. | 73 74## SystemBarRegionTint<sup>8+</sup> 75 76Describes the callback for a single system bar. 77 78**System API**: This is a system API and cannot be called by third-party applications. 79 80**System capability**: SystemCapability.WindowManager.WindowManager.Core 81 82| Name | Type | Readable| Writable| Description | 83| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | 84| type | [WindowType](#windowtype7) | Yes | No | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.| 85| isEnable | boolean | Yes | No | Whether the system bar is displayed. | 86| region | [Rect](#rect7) | Yes | No | Current position and size of the system bar. | 87| backgroundColor | string | Yes | No | Background color of the system bar. The value is a hexadecimal RGB or ARGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`. | 88| contentColor | string | Yes | No | Color of the text on the system bar. | 89 90## SystemBarTintState<sup>8+</sup> 91 92Describes the callback for the current system bar. 93 94**System API**: This is a system API and cannot be called by third-party applications. 95 96**System capability**: SystemCapability.WindowManager.WindowManager.Core 97 98| Name | Type | Readable| Writable| Description | 99| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- | 100| displayId | number | Yes | No | ID of the current physical screen. | 101| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | Yes | No | All system bar information that has been changed.| 102 103## Rect<sup>7+</sup> 104 105Describes the rectangular area of the window. 106 107**System capability**: SystemCapability.WindowManager.WindowManager.Core 108 109| Name | Type| Readable| Writable| Description | 110| ------ | -------- | ---- | ---- | ------------------ | 111| left | number | Yes | Yes | Left boundary of the rectangle.| 112| top | number | Yes | Yes | Top boundary of the rectangle.| 113| width | number | Yes | Yes | Width of the rectangle. | 114| height | number | Yes | Yes | Height of the rectangle. | 115 116## AvoidArea<sup>7+</sup> 117 118Describes the area where the window cannot be displayed. 119 120**System capability**: SystemCapability.WindowManager.WindowManager.Core 121 122| Name | Type | Readable| Writable| Description | 123| ---------- | ------------- | ---- | ---- | ------------------ | 124| leftRect | [Rect](#rect7) | Yes | Yes | Rectangle on the left of the screen.| 125| topRect | [Rect](#rect7) | Yes | Yes | Rectangle at the top of the screen.| 126| rightRect | [Rect](#rect7) | Yes | Yes | Rectangle on the right of the screen.| 127| bottomRect | [Rect](#rect7) | Yes | Yes | Rectangle at the bottom of the screen.| 128 129## Size<sup>7+</sup> 130 131Describes the window size. 132 133**System capability**: SystemCapability.WindowManager.WindowManager.Core 134 135| Name | Type| Readable| Writable| Description | 136| ------ | -------- | ---- | ---- | ---------- | 137| width | number | Yes | Yes | Window width.| 138| height | number | Yes | Yes | Window height.| 139 140## WindowProperties 141 142Describes the window properties. 143 144**System capability**: SystemCapability.WindowManager.WindowManager.Core 145 146| Name | Type | Readable| Writable| Description | 147| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- | 148| windowRect<sup>7+</sup> | [Rect](#rect7) | Yes | Yes | Window size. | 149| type<sup>7+</sup> | [WindowType](#windowtype7) | Yes | Yes | Window type. | 150| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is `false`. | 151| isLayoutFullScreen<sup>7+</sup> | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is `false`. | 152| focusable<sup>7+</sup> | boolean | Yes | No | Whether the window can gain focus. The default value is `true`. | 153| touchable<sup>7+</sup> | boolean | Yes | No | Whether the window is touchable. The default value is `true`. | 154| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value `1` indicates the maximum brightness. | 155| dimBehindValue<sup>7+</sup> | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.| 156| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is `false`. | 157| isPrivacyMode<sup>7+</sup> | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is `false`. | 158| isRoundCorner<sup>7+</sup> | boolean | Yes | Yes | Whether the window has rounded corners. The default value is `false`. | 159| isTransparent<sup>7+</sup> | boolean | Yes | Yes | Whether the window is transparent. The default value is `false`. | 160 161## ColorSpace<sup>8+</sup> 162 163Describes the color gamut mode. 164 165**System capability**: SystemCapability.WindowManager.WindowManager.Core 166 167| Name | Default Value | Description | 168| ---------- | ------ | -------------- | 169| DEFAULT | 0 | Default color gamut mode.| 170| WIDE_GAMUT | 1 | Wide color gamut mode. | 171 172## window.create<sup>7+</sup> 173 174create(id: string, type: WindowType, callback: AsyncCallback<Window>): void 175 176Creates a subwindow. This API uses an asynchronous callback to return the result. 177 178**System capability**: SystemCapability.WindowManager.WindowManager.Core 179 180**Parameters** 181 182| Name | Type | Mandatory| Description | 183| -------- | -------------------------------------- | ---- | ------------------------------------ | 184| id | string | Yes | Window ID. | 185| type | [WindowType](#windowtype7) | Yes | Window type. | 186| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| 187 188**Example** 189 190```js 191var windowClass = null; 192window.create("first", window.WindowType.TYPE_APP,(err,data) => { 193 if(err.code){ 194 console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); 195 return; 196 } 197 windowClass = data; 198 console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); 199}); 200``` 201 202## window.create<sup>7+</sup> 203 204create(id: string, type: WindowType): Promise<Window> 205 206Creates a subwindow. This API uses a promise to return the result. 207 208**System capability**: SystemCapability.WindowManager.WindowManager.Core 209 210**Parameters** 211 212| Name| Type | Mandatory| Description | 213| ------ | ------------------------- | ---- | ---------- | 214| id | string | Yes | Window ID. | 215| type | [WindowType](#windowtype7) | Yes | Window type.| 216 217**Return value** 218 219| Type | Description | 220| -------------------------------- | --------------------------------------- | 221| Promise<[Window](#window)> | Promise used to return the subwindow created.| 222 223**Example** 224 225```js 226var windowClass = null; 227let promise = window.create("first", window.WindowType.TYPE_APP); 228promise.then((data)=> { 229 windowClass = data; 230 console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); 231}).catch((err)=>{ 232 console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); 233}); 234``` 235 236## window.create<sup>8+</sup> 237 238create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void 239 240Creates a subwindow. This API uses an asynchronous callback to return the result. 241 242**System capability**: SystemCapability.WindowManager.WindowManager.Core 243 244**Parameters** 245 246| Name | Type | Mandatory| Description | 247| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | 248| ctx | [Context](js-apis-Context.md) | Yes | Current application context.| 249| id | string | Yes | Window ID. | 250| type | [WindowType](#windowtype7) | Yes | Window type. | 251| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created. | 252 253**Example** 254 255```js 256var windowClass = null; 257 window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { 258 if (err.code) { 259 console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); 260 return; 261 } 262 windowClass = data; 263 console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); 264 windowClass.resetSize(500, 1000); 265}); 266``` 267 268## window.create<sup>8+</sup> 269 270create(ctx: Context, id: string, type: WindowType): Promise<Window> 271 272Creates a subwindow. This API uses a promise to return the result. 273 274 275**System capability**: SystemCapability.WindowManager.WindowManager.Core 276 277**Parameters** 278 279| Name| Type | Mandatory| Description | 280| ------ | ------------------------- | ---- | ------------------------------------------------------------ | 281| ctx | [Context](js-apis-Context.md) | Yes | Current application context.| 282| id | string | Yes | Window ID. | 283| type | [WindowType](#windowtype7) | Yes | Window type. | 284 285**Return value** 286 287| Type | Description | 288| -------------------------------- | --------------------------------------- | 289| Promise<[Window](#window)> | Promise used to return the subwindow created.| 290 291**Example** 292 293```js 294var windowClass = null; 295let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); 296promise.then((data)=> { 297 windowClass = data; 298 console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); 299}).catch((err)=>{ 300 console.error('Failed to create the window. Cause:' + JSON.stringify(err)); 301}); 302``` 303 304## window.find<sup>7+</sup> 305 306find(id: string, callback: AsyncCallback<Window>): void 307 308Finds a window based on the ID. This API uses an asynchronous callback to return the result. 309 310**System capability**: SystemCapability.WindowManager.WindowManager.Core 311 312**Parameters** 313 314| Name | Type | Mandatory| Description | 315| -------- | -------------------------------------- | ---- | ------------------------------------ | 316| id | string | Yes | Window ID. | 317| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window found.| 318 319**Example** 320 321```js 322var windowClass = null; 323 window.find("alertWindow", (err, data) => { 324 if (err.code) { 325 console.error('Failed to find the window. Cause: ' + JSON.stringify(err)); 326 return; 327 } 328 windowClass = data; 329 console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); 330}); 331``` 332 333## window.find<sup>7+</sup> 334 335find(id: string): Promise<Window> 336 337Finds a window based on the ID. This API uses a promise to return the result. 338 339**System capability**: SystemCapability.WindowManager.WindowManager.Core 340 341**Parameters** 342 343| Name| Type | Mandatory| Description | 344| ------ | ------ | ---- | -------- | 345| id | string | Yes | Window ID.| 346 347**Return value** 348 349| Type | Description | 350| -------------------------------- | ------------------------------------- | 351| Promise<[Window](#window)> | Promise used to return the window found.| 352 353**Example** 354 355```js 356var windowClass = null; 357let promise = window.find("alertWindow"); 358promise.then((data)=> { 359 windowClass = data; 360 console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); 361}).catch((err)=>{ 362 console.error('Failed to find the window. Cause: ' + JSON.stringify(err)); 363}); 364``` 365 366## window.getTopWindow 367 368getTopWindow(callback: AsyncCallback<Window>): void 369 370Obtains the top window of the current application. This API uses an asynchronous callback to return the result. 371 372**System capability**: SystemCapability.WindowManager.WindowManager.Core 373 374**Parameters** 375 376| Name | Type | Mandatory| Description | 377| -------- | -------------------------------------- | ---- | -------------------------------------------- | 378| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.| 379 380**Example** 381 382```js 383var windowClass = null; 384window.getTopWindow((err, data) => { 385 if (err.code) { 386 console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); 387 return; 388 } 389 windowClass = data; 390 console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); 391}); 392``` 393 394## window.getTopWindow 395 396getTopWindow(): Promise<Window> 397 398Obtains the top window of the current application. This API uses a promise to return the result. 399 400**System capability**: SystemCapability.WindowManager.WindowManager.Core 401 402**Return value** 403 404| Type | Description | 405| -------------------------------- | ----------------------------------------------- | 406| Promise<[Window](#window)> | Promise used to return the top window obtained.| 407 408**Example** 409 410```js 411var windowClass = null; 412let promise = window.getTopWindow(); 413promise.then((data)=> { 414 windowClass = data; 415 console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); 416}).catch((err)=>{ 417 console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); 418}) 419``` 420 421## window.getTopWindow<sup>8+</sup> 422 423getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void 424 425Obtains the top window of the current application. This API uses an asynchronous callback to return the result. 426 427**System capability**: SystemCapability.WindowManager.WindowManager.Core 428 429**Parameters** 430 431| Name | Type | Mandatory| Description | 432| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | 433| ctx | [Context](js-apis-Context.md) | Yes | Current application context. | 434| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. | 435 436**Example** 437 438```js 439var windowClass = null; 440window.getTopWindow(this.context, (err, data) => { 441 if (err.code) { 442 console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); 443 return; 444 } 445 windowClass = data; 446 console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); 447}); 448``` 449 450## window.getTopWindow<sup>8+</sup> 451 452getTopWindow(ctx: Context): Promise<Window> 453 454Obtains the top window of the current application. This API uses a promise to return the result. 455 456**System capability**: SystemCapability.WindowManager.WindowManager.Core 457 458**Parameters** 459 460| Name| Type | Mandatory| Description | 461| ------ | ------- | ---- | ------------------------------------------------------------ | 462| ctx | [Context](js-apis-Context.md) | Yes | Current application context.| 463 464**Return value** 465 466| Type | Description | 467| -------------------------------- | ----------------------------------------------- | 468| Promise<[Window](#window)> | Promise used to return the top window obtained.| 469 470**Example** 471 472```js 473var windowClass = null; 474let promise = window.getTopWindow(this.context); 475promise.then((data)=> { 476 windowClass = data; 477 console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); 478}).catch((err)=>{ 479 console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); 480}) 481``` 482 483## on('systemBarTintChange')<sup>8+</sup> 484 485on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void 486 487Enables listening for properties changes of the status bar and navigation bar. 488 489**System API**: This is a system API and cannot be called by third-party applications. 490 491**System capability**: SystemCapability.WindowManager.WindowManager.Core 492 493**Parameters** 494 495| Name | Type | Mandatory| Description | 496| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | 497| type | string | Yes | Event type. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.| 498| callback | Callback<[SystemBarTintState](#systembartintstate8)> | Yes | Callback used to return the properties of the status bar and navigation bar. | 499 500**Example** 501 502```js 503window.on('systemBarTintChange', (data) => { 504 console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); 505}); 506``` 507 508## off('systemBarTintChange')<sup>8+</sup> 509 510off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void 511 512Disables listening for properties changes of the status bar and navigation bar. 513 514**System API**: This is a system API and cannot be called by third-party applications. 515 516**System capability**: SystemCapability.WindowManager.WindowManager.Core 517 518**Parameters** 519 520| Name | Type | Mandatory| Description | 521| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | 522| type | string | Yes | Event type. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.| 523| callback | Callback<[SystemBarTintState](#systembartintstate8)> | No | Callback used to return the properties of the status bar and navigation bar. | 524 525**Example** 526 527```js 528window.off('systemBarTintChange'); 529``` 530 531## Window 532 533Represents the current window instance, which is the basic unit managed by the window manager. 534 535In the following API examples, you must use [getTopWindow()](#windowgettopwindow), [create()](#windowcreate7), or [find()](#windowfind7) to obtain a `Window` instance and then call a method in this instance. 536 537### hide<sup>7+</sup> 538 539hide (callback: AsyncCallback<void>): void 540 541Hides this window. This API uses an asynchronous callback to return the result. 542 543**System API**: This is a system API and cannot be called by third-party applications. 544 545**System capability**: SystemCapability.WindowManager.WindowManager.Core 546 547**Parameters** 548 549| Name | Type | Mandatory| Description | 550| -------- | ------------------------- | ---- | ---------- | 551| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 552 553**Example** 554 555```js 556windowClass.hide((err, data) => { 557 if (err.code) { 558 console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); 559 return; 560 } 561 console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data)); 562}) 563``` 564 565### hide<sup>7+</sup> 566 567hide(): Promise<void> 568 569Hides this window. This API uses a promise to return the result. 570 571**System API**: This is a system API and cannot be called by third-party applications. 572 573**System capability**: SystemCapability.WindowManager.WindowManager.Core 574 575**Return value** 576 577| Type | Description | 578| ------------------- | ------------------------- | 579| Promise<void> | Promise that returns no value.| 580 581**Example** 582 583```js 584let promise = windowClass.hide(); 585promise.then((data)=> { 586 console.info('Succeeded in hiding the window. Data: ' + JSON.stringify(data)); 587}).catch((err)=>{ 588 console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); 589}) 590``` 591 592### show<sup>7+</sup> 593 594show(callback: AsyncCallback<void>): void 595 596Shows this window. This API uses an asynchronous callback to return the result. 597 598**System capability**: SystemCapability.WindowManager.WindowManager.Core 599 600**Parameters** 601 602| Name | Type | Mandatory| Description | 603| -------- | ------------------------- | ---- | ---------- | 604| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 605 606**Example** 607 608```js 609windowClass.show((err, data) => { 610 if (err.code) { 611 console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); 612 return; 613 } 614 console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); 615}) 616``` 617 618### show<sup>7+</sup> 619 620show(): Promise<void> 621 622Shows this window. This API uses a promise to return the result. 623 624**System capability**: SystemCapability.WindowManager.WindowManager.Core 625 626**Return value** 627 628| Type | Description | 629| ------------------- | ------------------------- | 630| Promise<void> | Promise that returns no value.| 631 632**Example** 633 634```js 635let promise = windowClass.show(); 636promise.then((data)=> { 637 console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); 638}).catch((err)=>{ 639 console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); 640}) 641``` 642 643### destroy<sup>7+</sup> 644 645destroy(callback: AsyncCallback<void>): void 646 647Destroys this window. This API uses an asynchronous callback to return the result. 648 649**System capability**: SystemCapability.WindowManager.WindowManager.Core 650 651**Parameters** 652 653| Name | Type | Mandatory| Description | 654| -------- | ------------------------- | ---- | ---------- | 655| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 656 657**Example** 658 659```js 660windowClass.destroy((err, data) => { 661 if (err.code) { 662 console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); 663 return; 664 } 665 console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); 666}) 667``` 668 669### destroy<sup>7+</sup> 670 671destroy(): Promise<void> 672 673Destroys this window. This API uses a promise to return the result. 674 675**System capability**: SystemCapability.WindowManager.WindowManager.Core 676 677**Return value** 678 679| Type | Description | 680| ------------------- | ------------------------- | 681| Promise<void> | Promise that returns no value.| 682 683**Example** 684 685```js 686let promise = windowClass.destroy(); 687promise.then((data)=> { 688 console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); 689}).catch((err)=>{ 690 console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); 691}) 692``` 693 694### moveTo<sup>7+</sup> 695 696moveTo(x: number, y: number, callback: AsyncCallback<void>): void 697 698Moves this window. This API uses an asynchronous callback to return the result. 699 700**System capability**: SystemCapability.WindowManager.WindowManager.Core 701 702**Parameters** 703 704| Name | Type | Mandatory| Description | 705| -------- | ------------------------- | ---- | ------------------------------------------------- | 706| x | number | Yes | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.| 707| y | number | Yes | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.| 708| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 709 710**Example** 711 712```js 713windowClass.moveTo(300, 300, (err, data)=>{ 714 if (err.code) { 715 console.error('Failed to move the window. Cause:' + JSON.stringify(err)); 716 return; 717 } 718 console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); 719 720}); 721``` 722 723### moveTo<sup>7+</sup> 724 725moveTo(x: number, y: number): Promise<void> 726 727Moves this window. This API uses a promise to return the result. 728 729**System capability**: SystemCapability.WindowManager.WindowManager.Core 730 731**Parameters** 732 733| Name| Type | Mandatory| Description | 734| ------ | ------ | ---- | ------------------------------------------------- | 735| x | number | Yes | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.| 736| y | number | Yes | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.| 737 738**Return value** 739 740| Type | Description | 741| ------------------- | ------------------------- | 742| Promise<void> | Promise that returns no value.| 743 744**Example** 745 746```js 747let promise = windowClass.moveTo(300, 300); 748promise.then((data)=> { 749 console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); 750}).catch((err)=>{ 751 console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); 752}) 753``` 754 755### resetSize<sup>7+</sup> 756 757resetSize(width: number, height: number, callback: AsyncCallback<void>): void 758 759Changes the size of this window. This API uses an asynchronous callback to return the result. 760 761The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp. 762 763The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp. 764 765**System capability**: SystemCapability.WindowManager.WindowManager.Core 766 767**Parameters** 768 769| Name | Type | Mandatory| Description | 770| -------- | ------------------------- | ---- | -------------------------- | 771| width | number | Yes | New width of the window, in px.| 772| height | number | Yes | New height of the window, in px.| 773| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 774 775**Example** 776 777```js 778windowClass.resetSize(500, 1000, (err, data) => { 779 if (err.code) { 780 console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); 781 return; 782 } 783 console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); 784}); 785``` 786 787### resetSize<sup>7+</sup> 788 789resetSize(width: number, height: number): Promise<void> 790 791Changes the size of this window. This API uses a promise to return the result. 792 793The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp. 794 795The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp. 796 797**System capability**: SystemCapability.WindowManager.WindowManager.Core 798 799**Parameters** 800 801| Name| Type | Mandatory| Description | 802| ------ | ------ | ---- | -------------------------- | 803| width | number | Yes | New width of the window, in px.| 804| height | number | Yes | New height of the window, in px.| 805 806**Return value** 807 808| Type | Description | 809| ------------------- | ------------------------- | 810| Promise<void> | Promise that returns no value.| 811 812**Example** 813 814```js 815let promise = windowClass.resetSize(500, 1000); 816promise.then((data)=> { 817 console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); 818}).catch((err)=>{ 819 console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); 820}); 821``` 822 823### setWindowType<sup>7+</sup> 824 825setWindowType(type: WindowType, callback: AsyncCallback<void>): void 826 827Sets the type of this window. This API uses an asynchronous callback to return the result. 828 829**System API**: This is a system API and cannot be called by third-party applications. 830 831**System capability**: SystemCapability.WindowManager.WindowManager.Core 832 833**Parameters** 834 835| Name | Type | Mandatory| Description | 836| -------- | ------------------------- | ---- | ---------- | 837| type | [WindowType](#windowtype7) | Yes | Window type.| 838| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 839 840**Example** 841 842```js 843var type = window.WindowType.TYPE_APP; 844windowClass.setWindowType(type, (err, data) => { 845 if (err.code) { 846 console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); 847 return; 848 } 849 console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)); 850}); 851``` 852 853### setWindowType<sup>7+</sup> 854 855setWindowType(type: WindowType): Promise<void> 856 857Sets the type of this window. This API uses a promise to return the result. 858 859**System API**: This is a system API and cannot be called by third-party applications. 860 861**System capability**: SystemCapability.WindowManager.WindowManager.Core 862 863**Parameters** 864 865| Name| Type | Mandatory| Description | 866| ------ | ------------------------- | ---- | ---------- | 867| type | [WindowType](#windowtype7) | Yes | Window type.| 868 869**Return value** 870 871| Type | Description | 872| ------------------- | ------------------------- | 873| Promise<void> | Promise that returns no value.| 874 875**Example** 876 877```js 878var type = window.WindowType.TYPE_APP; 879let promise = windowClass.setWindowType(type); 880promise.then((data)=> { 881 console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)); 882}).catch((err)=>{ 883 console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); 884}); 885``` 886 887### getProperties 888 889getProperties(callback: AsyncCallback<WindowProperties>): void 890 891Obtains the properties of this window. This API uses an asynchronous callback to return the result. 892 893**System capability**: SystemCapability.WindowManager.WindowManager.Core 894 895**Parameters** 896 897| Name | Type | Mandatory| Description | 898| -------- | ---------------------------------------------------------- | ---- | ---------------------------- | 899| callback | AsyncCallback<[WindowProperties](#windowproperties)> | Yes | Callback used to return the window properties.| 900 901**Example** 902 903```js 904windowClass.getProperties((err, data) => { 905 if (err.code) { 906 console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); 907 return; 908 } 909 console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); 910}); 911``` 912 913### getProperties 914 915getProperties(): Promise<WindowProperties> 916 917Obtains the properties of this window. This API uses a promise to return the result. 918 919**System capability**: SystemCapability.WindowManager.WindowManager.Core 920 921**Return value** 922 923| Type | Description | 924| ---------------------------------------------------- | ------------------------------- | 925| Promise<[WindowProperties](#windowproperties)> | Promise used to return the window properties.| 926 927**Example** 928 929```js 930let promise = windowClass.getProperties(); 931promise.then((data)=> { 932 console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); 933}).catch((err)=>{ 934 console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); 935}); 936``` 937 938### getAvoidArea<sup>7+</sup> 939 940getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): void 941 942Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses an asynchronous callback to return the result. 943 944**System capability**: SystemCapability.WindowManager.WindowManager.Core 945 946**Parameters** 947 948| Name | Type | Mandatory| Description | 949| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | 950| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch.| 951| callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | 952 953**Example** 954 955```js 956var type = window.AvoidAreaType.TYPE_SYSTEM; 957windowClass.getAvoidArea(type, (err, data) => { 958 if (err.code) { 959 console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); 960 return; 961 } 962 console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); 963}); 964``` 965 966### getAvoidArea<sup>7+</sup> 967 968getAvoidArea(type: AvoidAreaType): Promise<AvoidArea> 969 970Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses a promise to return the result. 971 972**System capability**: SystemCapability.WindowManager.WindowManager.Core 973 974**Parameters** 975 976| Name| Type | Mandatory| Description | 977| ------ | ------------------------------- | ---- | ------------------------------------------------------------ | 978| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch.| 979 980**Return value** 981 982| Type | Description | 983| -------------------------------------- | ----------------------------------- | 984| Promise<[AvoidArea](#avoidarea)> | Promise used to return the area.| 985 986**Example** 987 988```js 989var type = window.AvoidAreaType.TYPE_SYSTEM; 990let promise = windowClass.getAvoidArea(type); 991promise.then((data)=> { 992 console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); 993}).catch((err)=>{ 994 console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); 995}); 996``` 997 998### setFullScreen 999 1000setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void 1001 1002Sets whether to enable the full-screen mode for this window. This API uses an asynchronous callback to return the result. 1003 1004**System capability**: SystemCapability.WindowManager.WindowManager.Core 1005 1006**Parameters** 1007 1008| Name | Type | Mandatory| Description | 1009| ------------ | ------------------------- | ---- | ---------------------------------------------- | 1010| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| 1011| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1012 1013**Example** 1014 1015```js 1016var isFullScreen = true; 1017windowClass.setFullScreen(isFullScreen, (err, data) => { 1018 if (err.code) { 1019 console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); 1020 return; 1021 } 1022 console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); 1023}); 1024``` 1025 1026### setFullScreen 1027 1028setFullScreen(isFullScreen: boolean): Promise<void> 1029 1030Sets whether to enable the full-screen mode for this window. This API uses a promise to return the result. 1031 1032**System capability**: SystemCapability.WindowManager.WindowManager.Core 1033 1034**Parameters** 1035 1036| Name | Type | Mandatory| Description | 1037| ------------ | ------- | ---- | ---------------------------------------------- | 1038| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| 1039 1040**Return value** 1041 1042| Type | Description | 1043| ------------------- | ------------------------- | 1044| Promise<void> | Promise that returns no value.| 1045 1046**Example** 1047 1048```js 1049var isFullScreen = true; 1050let promise = windowClass.setFullScreen(isFullScreen); 1051promise.then((data)=> { 1052 console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); 1053}).catch((err)=>{ 1054 console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); 1055}); 1056``` 1057 1058### setLayoutFullScreen<sup>7+</sup> 1059 1060setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void 1061 1062Sets whether to enable the full-screen mode for the window layout. This API uses an asynchronous callback to return the result. 1063 1064**System capability**: SystemCapability.WindowManager.WindowManager.Core 1065 1066**Parameters** 1067 1068| Name | Type | Mandatory| Description | 1069| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | 1070| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.| 1071| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1072 1073**Example** 1074 1075```js 1076var isLayoutFullScreen= true; 1077windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { 1078 if (err.code) { 1079 console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); 1080 return; 1081 } 1082 console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); 1083}); 1084``` 1085 1086### setLayoutFullScreen<sup>7+</sup> 1087 1088setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> 1089 1090Sets whether to enable the full-screen mode for the window layout. This API uses a promise to return the result. 1091 1092**System capability**: SystemCapability.WindowManager.WindowManager.Core 1093 1094**Parameters** 1095 1096| Name | Type | Mandatory| Description | 1097| ------------------ | ------- | ---- | ------------------------------------------------------------ | 1098| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.| 1099 1100**Return value** 1101 1102| Type | Description | 1103| ------------------- | ------------------------- | 1104| Promise<void> | Promise that returns no value.| 1105 1106**Example** 1107 1108```js 1109var isLayoutFullScreen = true; 1110let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); 1111promise.then((data)=> { 1112 console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); 1113}).catch((err)=>{ 1114 console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); 1115}); 1116``` 1117 1118### setSystemBarEnable<sup>7+</sup> 1119 1120setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void 1121 1122Sets whether to display the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result. 1123 1124**System capability**: SystemCapability.WindowManager.WindowManager.Core 1125 1126**Parameters** 1127 1128| Name | Type | Mandatory| Description | 1129| -------- | ------------------------- | ---- | ------------------------------------------------------------ | 1130| names | Array | Yes | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.| 1131| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1132 1133**Example** 1134 1135```js 1136// In this example, the status bar and navigation bar are not displayed. 1137var names = []; 1138windowClass.setSystemBarEnable(names, (err, data) => { 1139 if (err.code) { 1140 console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); 1141 return; 1142 } 1143 console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); 1144}); 1145``` 1146 1147### setSystemBarEnable<sup>7+</sup> 1148 1149setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> 1150 1151Sets whether to display the status bar and navigation bar in this window. This API uses a promise to return the result. 1152 1153**System capability**: SystemCapability.WindowManager.WindowManager.Core 1154 1155**Parameters** 1156 1157| Name| Type | Mandatory| Description | 1158| ------ | ----- | ---- | ------------------------------------------------------------ | 1159| names | Array | Yes | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.| 1160 1161**Return value** 1162 1163| Type | Description | 1164| ------------------- | ------------------------- | 1165| Promise<void> | Promise that returns no value.| 1166 1167**Example** 1168 1169```js 1170// In this example, the status bar and navigation bar are not displayed. 1171var names = []; 1172let promise = windowClass.setSystemBarEnable(names); 1173promise.then((data)=> { 1174 console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); 1175}).catch((err)=>{ 1176 console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); 1177}); 1178``` 1179 1180### setSystemBarProperties 1181 1182setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void 1183 1184Sets the properties of the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result. 1185 1186**System capability**: SystemCapability.WindowManager.WindowManager.Core 1187 1188**Parameters** 1189 1190| Name | Type | Mandatory| Description | 1191| ------------------- | ------------------------------------------- | ---- | ---------------------- | 1192| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| 1193| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1194 1195**Example** 1196 1197```js 1198var SystemBarProperties={ 1199 statusBarColor: '#ff00ff', 1200 navigationBarColor: '#00ff00', 1201 // The following properties are supported since API version 8. 1202 statusBarContentColor:'#ffffff', 1203 navigationBarContentColor:'#00ffff' 1204}; 1205windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { 1206 if (err.code) { 1207 console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); 1208 return; 1209 } 1210 console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); 1211}); 1212``` 1213 1214### setSystemBarProperties 1215 1216setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> 1217 1218Sets the properties of the status bar and navigation bar in this window. This API uses a promise to return the result. 1219 1220**System capability**: SystemCapability.WindowManager.WindowManager.Core 1221 1222**Parameters** 1223 1224| Name | Type | Mandatory| Description | 1225| ------------------- | ------------------------------------------- | ---- | ---------------------- | 1226| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| 1227 1228**Return value** 1229 1230| Type | Description | 1231| ------------------- | ------------------------- | 1232| Promise<void> | Promise that returns no value.| 1233 1234**Example** 1235 1236```js 1237var SystemBarProperties={ 1238 statusBarColor: '#ff00ff', 1239 navigationBarColor: '#00ff00', 1240 // The following properties are supported since API version 8. 1241 statusBarContentColor:'#ffffff', 1242 navigationBarContentColor:'#00ffff' 1243}; 1244let promise = windowClass.setSystemBarProperties(SystemBarProperties); 1245promise.then((data)=> { 1246 console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); 1247}).catch((err)=>{ 1248 console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); 1249}); 1250``` 1251 1252### loadContent<sup>7+</sup> 1253 1254loadContent(path: string, callback: AsyncCallback<void>): void 1255 1256Loads content from a page to this window. This API uses an asynchronous callback to return the result. 1257 1258**System capability**: SystemCapability.WindowManager.WindowManager.Core 1259 1260**Parameters** 1261 1262| Name | Type | Mandatory| Description | 1263| -------- | ------------------------- | ---- | -------------------- | 1264| path | string | Yes | Path of the page from which the content will be loaded.| 1265| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1266 1267**Example** 1268 1269```js 1270windowClass.loadContent("pages/page2/page2", (err, data) => { 1271 if (err.code) { 1272 console.error('Failed to load the content. Cause:' + JSON.stringify(err)); 1273 return; 1274 } 1275 console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); 1276}); 1277``` 1278 1279### loadContent<sup>7+</sup> 1280 1281loadContent(path: string): Promise<void> 1282 1283Loads content from a page to this window. This API uses a promise to return the result. 1284 1285**System capability**: SystemCapability.WindowManager.WindowManager.Core 1286 1287**Parameters** 1288 1289| Name| Type | Mandatory| Description | 1290| ------ | ------ | ---- | -------------------- | 1291| path | string | Yes | Path of the page from which the content will be loaded.| 1292 1293**Return value** 1294 1295| Type | Description | 1296| ------------------- | ------------------------- | 1297| Promise<void> | Promise that returns no value.| 1298 1299**Example** 1300 1301```js 1302let promise = windowClass.loadContent("pages/page2/page2"); 1303promise.then((data)=> { 1304 console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); 1305}).catch((err)=>{ 1306 console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); 1307}); 1308``` 1309### isShowing<sup>7+</sup> 1310 1311isShowing(callback: AsyncCallback<boolean>): void 1312 1313Checks whether this window is displayed. This API uses an asynchronous callback to return the result. 1314 1315**System capability**: SystemCapability.WindowManager.WindowManager.Core 1316 1317**Parameters** 1318 1319| Name | Type | Mandatory| Description | 1320| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | 1321| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value `true` means that the window is displayed, and `false` means the opposite.| 1322 1323**Example** 1324 1325```js 1326windowClass.isShowing((err, data) => { 1327 if (err.code) { 1328 console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); 1329 return; 1330 } 1331 console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); 1332}); 1333``` 1334 1335### isShowing<sup>7+</sup> 1336 1337isShowing(): Promise<boolean> 1338 1339Checks whether this window is displayed. This API uses a promise to return the result. 1340 1341**System capability**: SystemCapability.WindowManager.WindowManager.Core 1342 1343**Return value** 1344 1345| Type | Description | 1346| ---------------------- | ------------------------------------------------------------ | 1347| Promise<boolean> | Promise used to return the result. The value `true` means that the window is displayed, and `false` means the opposite.| 1348 1349**Example** 1350 1351```js 1352let promise = windowClass.isShowing(); 1353promise.then((data)=> { 1354 console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); 1355}).catch((err)=>{ 1356 console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); 1357}); 1358``` 1359 1360### on('windowSizeChange')<sup>7+</sup> 1361 1362on(type: 'windowSizeChange', callback: Callback<Size>): void 1363 1364Enables listening for window size changes. 1365 1366**System capability**: SystemCapability.WindowManager.WindowManager.Core 1367 1368**Parameters** 1369 1370| Name | Type | Mandatory| Description | 1371| -------- | ------------------------------ | ---- | -------------------------------------------------------- | 1372| type | string | Yes | Event type. The value is fixed at `windowSizeChange`, indicating the window size change event.| 1373| callback | Callback<[Size](#size7)> | Yes | Callback used to return the window size. | 1374 1375**Example** 1376 1377```js 1378windowClass.on('windowSizeChange', (data) => { 1379 console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); 1380}); 1381``` 1382 1383### off('windowSizeChange')<sup>7+</sup> 1384 1385off(type: 'windowSizeChange', callback?: Callback<Size >): void 1386 1387Disables listening for window size changes. 1388 1389**System capability**: SystemCapability.WindowManager.WindowManager.Core 1390 1391**Parameters** 1392 1393| Name | Type | Mandatory| Description | 1394| -------- | ----------------------------- | ---- | -------------------------------------------------------- | 1395| type | string | Yes | Event type. The value is fixed at `windowSizeChange`, indicating the window size change event.| 1396| callback | Callback<[Size](#size)> | No | Callback used to return the window size. | 1397 1398**Example** 1399 1400```js 1401windowClass.off('windowSizeChange'); 1402``` 1403 1404### on('systemAvoidAreaChange')<sup>7+</sup> 1405 1406on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void 1407 1408Enables listening for changes to the area where the window cannot be displayed. 1409 1410**System capability**: SystemCapability.WindowManager.WindowManager.Core 1411 1412**Parameters** 1413 1414| Name | Type | Mandatory| Description | 1415| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | 1416| type | string | Yes | Event type. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.| 1417| callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | 1418 1419**Example** 1420 1421```js 1422windowClass.on('systemAvoidAreaChange', (data) => { 1423 console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); 1424}); 1425``` 1426 1427### off('systemAvoidAreaChange')<sup>7+</sup> 1428 1429off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void 1430 1431Disables listening for changes to the area where the window cannot be displayed. 1432 1433**System capability**: SystemCapability.WindowManager.WindowManager.Core 1434 1435**Parameters** 1436 1437| Name | Type | Mandatory| Description | 1438| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | 1439| type | string | Yes | Event type. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.| 1440| callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the area. | 1441 1442**Example** 1443 1444```js 1445windowClass.off('systemAvoidAreaChange'); 1446``` 1447 1448### on('keyboardHeightChange')<sup>7+</sup> 1449 1450on(type: 'keyboardHeightChange', callback: Callback<number>): void 1451 1452Enables listening for keyboard height changes. 1453 1454**System capability**: SystemCapability.WindowManager.WindowManager.Core 1455 1456**Parameters** 1457 1458| Name | Type | Mandatory| Description | 1459| -------- | ------------------- | ---- | ------------------------------------------------------------ | 1460| type | string | Yes | Event type. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.| 1461| callback | Callback<number> | Yes | Callback used to return the current keyboard height. | 1462 1463**Example** 1464 1465```js 1466windowClass.on('keyboardHeightChange', (data) => { 1467 console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); 1468}); 1469``` 1470 1471### off('keyboardHeightChange')<sup>7+</sup> 1472 1473off(type: 'keyboardHeightChange', callback?: Callback<number>): void 1474 1475Disables listening for keyboard height changes. 1476 1477**System capability**: SystemCapability.WindowManager.WindowManager.Core 1478 1479**Parameters** 1480 1481| Name | Type | Mandatory| Description | 1482| -------- | ---------------------- | ---- | ------------------------------------------------------------ | 1483| type | string | Yes | Event type. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.| 1484| callback | Callback<number> | No | Callback used to return the current keyboard height. | 1485 1486**Example** 1487 1488```js 1489windowClass.off('keyboardHeightChange'); 1490``` 1491 1492### isSupportWideGamut<sup>8+</sup> 1493 1494isSupportWideGamut(callback: AsyncCallback<boolean>): void 1495 1496Checks whether this window supports the wide color gamut mode. This API uses an asynchronous callback to return the result. 1497 1498**System capability**: SystemCapability.WindowManager.WindowManager.Core 1499 1500**Parameters** 1501 1502| Name | Type | Mandatory| Description | 1503| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | 1504| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.| 1505 1506**Example** 1507 1508```js 1509windowClass.isSupportWideGamut((err, data) => { 1510 if (err.code) { 1511 console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); 1512 return; 1513 } 1514 console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); 1515}) 1516``` 1517 1518### isSupportWideGamut<sup>8+</sup> 1519 1520isSupportWideGamut(): Promise<boolean> 1521 1522Checks whether this window supports the wide color gamut mode. This API uses a promise to return the result. 1523 1524**System capability**: SystemCapability.WindowManager.WindowManager.Core 1525 1526**Return value** 1527 1528| Type | Description | 1529| ---------------------- | ------------------------------------------------------------ | 1530| Promise<boolean> | Promise used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.| 1531 1532**Example** 1533 1534```js 1535let promise = windowClass.isSupportWideGamut(); 1536promise.then((data)=> { 1537 console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)); 1538}).catch((err)=>{ 1539 console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); 1540}); 1541``` 1542 1543### setColorSpace<sup>8+</sup> 1544 1545setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void 1546 1547Sets this window to the wide or default color gamut mode. This API uses an asynchronous callback to return the result. 1548 1549**System capability**: SystemCapability.WindowManager.WindowManager.Core 1550 1551**Parameters** 1552 1553| Name | Type | Mandatory| Description | 1554| ---------- | ------------------------- | ---- | ------------ | 1555| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| 1556| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1557 1558**Example** 1559 1560```js 1561windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { 1562 if (err.code) { 1563 console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); 1564 return; 1565 } 1566 console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)); 1567}) 1568``` 1569 1570### setColorSpace<sup>8+</sup> 1571 1572setColorSpace(colorSpace:ColorSpace): Promise<void> 1573 1574Sets this window to the wide or default color gamut mode. This API uses a promise to return the result. 1575 1576**System capability**: SystemCapability.WindowManager.WindowManager.Core 1577 1578**Parameters** 1579 1580| Name | Type | Mandatory| Description | 1581| ---------- | ------------------------- | ---- | -------------- | 1582| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| 1583 1584**Return value** 1585 1586| Type | Description | 1587| ------------------- | ------------------------- | 1588| Promise<void> | Promise that returns no value.| 1589 1590**Example** 1591 1592```js 1593let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT); 1594promise.then((data)=> { 1595 console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)); 1596}).catch((err)=>{ 1597 console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); 1598}); 1599``` 1600 1601### getColorSpace<sup>8+</sup> 1602 1603getColorSpace(callback: AsyncCallback<ColorSpace>): void 1604 1605Obtains the color gamut mode of this window. This API uses an asynchronous callback to return the result. 1606 1607**System capability**: SystemCapability.WindowManager.WindowManager.Core 1608 1609**Parameters** 1610 1611| Name | Type | Mandatory| Description | 1612| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- | 1613| callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the result. When the color gamut mode is obtained successfully, `err` is `undefined`, and `data` is the current color gamut mode.| 1614 1615**Example** 1616 1617```js 1618windowClass.getColorSpace((err, data) => { 1619 if (err.code) { 1620 console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err)); 1621 return; 1622 } 1623 console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)); 1624}) 1625``` 1626 1627### getColorSpace<sup>8+</sup> 1628 1629getColorSpace(): Promise<ColorSpace> 1630 1631Obtains the color gamut mode of this window. This API uses a promise to return the result. 1632 1633**System capability**: SystemCapability.WindowManager.WindowManager.Core 1634 1635**Return value** 1636 1637| Type | Description | 1638| ---------------------------------------- | ------------------------------- | 1639| Promise<[ColorSpace](#colorspace)> | Promise used to return the current color gamut mode.| 1640 1641**Example** 1642 1643```js 1644let promise = windowClass.getColorSpace(); 1645promise.then((data)=> { 1646 console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)); 1647}).catch((err)=>{ 1648 console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err)); 1649}); 1650``` 1651 1652### setBackgroundColor 1653 1654setBackgroundColor(color: string, callback: AsyncCallback<void>): void 1655 1656Sets the background color for this window. This API uses an asynchronous callback to return the result. 1657 1658**System capability**: SystemCapability.WindowManager.WindowManager.Core 1659 1660**Parameters** 1661 1662| Name | Type | Mandatory| Description | 1663| -------- | ------------------------- | ---- | ------------------------------------------------------------ | 1664| color | string | Yes | Background color to set. The value is a hexadecimal RGB or ARGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`. | 1665| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1666 1667**Example** 1668 1669```js 1670var color = '#00ff33'; 1671windowClass.setBackgroundColor(color, (err, data) => { 1672 if (err.code) { 1673 console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); 1674 return; 1675 } 1676 console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); 1677}); 1678``` 1679 1680### setBackgroundColor 1681 1682setBackgroundColor(color: string): Promise<void> 1683 1684Sets the background color for this window. This API uses a promise to return the result. 1685 1686**System capability**: SystemCapability.WindowManager.WindowManager.Core 1687 1688**Parameters** 1689 1690| Name| Type | Mandatory| Description | 1691| ------ | ------ | ---- | ------------------------------------------------------------ | 1692| color | string | Yes | Background color to set. The value is a hexadecimal RGB or ARGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`. | 1693 1694**Return value** 1695 1696| Type | Description | 1697| ------------------- | ------------------------- | 1698| Promise<void> | Promise that returns no value.| 1699 1700**Example** 1701 1702```js 1703var color = '#00ff33'; 1704let promise = windowClass.setBackgroundColor(color); 1705promise.then((data)=> { 1706 console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); 1707}).catch((err)=>{ 1708 console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); 1709}); 1710``` 1711 1712### setBrightness 1713 1714setBrightness(brightness: number, callback: AsyncCallback<void>): void 1715 1716Sets the screen brightness for this window. This API uses an asynchronous callback to return the result. 1717 1718**System capability**: SystemCapability.WindowManager.WindowManager.Core 1719 1720**Parameters** 1721 1722| Name | Type | Mandatory| Description | 1723| ---------- | ------------------------- | ---- | ------------------------------------ | 1724| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.| 1725| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1726 1727**Example** 1728 1729```js 1730var brightness = 1; 1731windowClass.setBrightness(brightness, (err, data) => { 1732 if (err.code) { 1733 console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); 1734 return; 1735 } 1736 console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); 1737}); 1738``` 1739 1740### setBrightness 1741 1742setBrightness(brightness: number): Promise<void> 1743 1744Sets the screen brightness for this window. This API uses a promise to return the result. 1745 1746**System capability**: SystemCapability.WindowManager.WindowManager.Core 1747 1748**Parameters** 1749 1750| Name | Type | Mandatory| Description | 1751| ---------- | ------ | ---- | ------------------------------------ | 1752| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.| 1753 1754**Return value** 1755 1756| Type | Description | 1757| ------------------- | ------------------------- | 1758| Promise<void> | Promise that returns no value.| 1759 1760**Example** 1761 1762```js 1763var brightness = 1; 1764let promise = windowClass.setBrightness(brightness); 1765promise.then((data)=> { 1766 console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); 1767}).catch((err)=>{ 1768 console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); 1769}); 1770``` 1771 1772### setDimBehind<sup>7+</sup> 1773 1774setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void 1775 1776Sets the dimness of the window that is not on top. This API uses an asynchronous callback to return the result. 1777 1778> **NOTE** 1779> 1780> This API cannot be used. 1781 1782**System capability**: SystemCapability.WindowManager.WindowManager.Core 1783 1784**Parameters** 1785 1786| Name | Type | Mandatory| Description | 1787| -------------- | ------------------------- | ---- | -------------------------------------------------- | 1788| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.| 1789| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1790 1791**Example** 1792 1793```js 1794windowClass.setDimBehind(0.5, (err, data) => { 1795 if (err.code) { 1796 console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); 1797 return; 1798 } 1799 console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); 1800}); 1801``` 1802 1803### setDimBehind<sup>7+</sup> 1804 1805setDimBehind(dimBehindValue: number): Promise<void> 1806 1807Sets the dimness of the window that is not on top. This API uses a promise to return the result. 1808 1809> **NOTE** 1810> 1811> This API cannot be used. 1812 1813**System capability**: SystemCapability.WindowManager.WindowManager.Core 1814 1815**Parameters** 1816 1817| Name | Type | Mandatory| Description | 1818| -------------- | ------ | ---- | -------------------------------------------------- | 1819| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.| 1820 1821**Return value** 1822 1823| Type | Description | 1824| ------------------- | ------------------------- | 1825| Promise<void> | Promise that returns no value.| 1826 1827**Example** 1828 1829```js 1830let promise = windowClass.setDimBehind(0.5); 1831promise.then((data)=> { 1832 console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)); 1833}).catch((err)=>{ 1834 console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); 1835}); 1836``` 1837 1838### setFocusable<sup>7+</sup> 1839 1840setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void 1841 1842Sets whether this window can gain focus. This API uses an asynchronous callback to return the result. 1843 1844**System capability**: SystemCapability.WindowManager.WindowManager.Core 1845 1846**Parameters** 1847 1848| Name | Type | Mandatory| Description | 1849| ----------- | ------------------------- | ---- | ---------------------------- | 1850| isFocusable | boolean | Yes | Whether the window can gain focus.| 1851| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1852 1853**Example** 1854 1855```js 1856var isFocusable= true; 1857windowClass.setFocusable(isFocusable, (err, data) => { 1858 if (err.code) { 1859 console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); 1860 return; 1861 } 1862 console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); 1863}); 1864``` 1865 1866### setFocusable<sup>7+</sup> 1867 1868setFocusable(isFocusable: boolean): Promise<void> 1869 1870Sets whether this window can gain focus. This API uses a promise to return the result. 1871 1872**System capability**: SystemCapability.WindowManager.WindowManager.Core 1873 1874**Parameters** 1875 1876| Name | Type | Mandatory| Description | 1877| ----------- | ------- | ---- | ---------------------------- | 1878| isFocusable | boolean | Yes | Whether the window can gain focus.| 1879 1880**Return value** 1881 1882| Type | Description | 1883| ------------------- | ------------------------- | 1884| Promise<void> | Promise that returns no value.| 1885 1886**Example** 1887 1888```js 1889var isFocusable= true; 1890let promise = windowClass.setFocusable(isFocusable); 1891promise.then((data)=> { 1892 console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); 1893}).catch((err)=>{ 1894 console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); 1895}); 1896``` 1897 1898### setKeepScreenOn 1899 1900setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void 1901 1902Sets whether to keep the screen always on. This API uses an asynchronous callback to return the result. 1903 1904**System capability**: SystemCapability.WindowManager.WindowManager.Core 1905 1906**Parameters** 1907 1908| Name | Type | Mandatory| Description | 1909| -------------- | ------------------------- | ---- | ------------------------ | 1910| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| 1911| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1912 1913**Example** 1914 1915```js 1916var isKeepScreenOn = true; 1917windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { 1918 if (err.code) { 1919 console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); 1920 return; 1921 } 1922 console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); 1923}); 1924``` 1925 1926### setKeepScreenOn 1927 1928setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> 1929 1930Sets whether to keep the screen always on. This API uses a promise to return the result. 1931 1932**System capability**: SystemCapability.WindowManager.WindowManager.Core 1933 1934**Parameters** 1935 1936| Name | Type | Mandatory| Description | 1937| -------------- | ------- | ---- | ------------------------ | 1938| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| 1939 1940**Return value** 1941 1942| Type | Description | 1943| ------------------- | ------------------------- | 1944| Promise<void> | Promise that returns no value.| 1945 1946**Example** 1947 1948```js 1949var isKeepScreenOn = true; 1950let promise = windowClass.setKeepScreenOn(isKeepScreenOn); 1951promise.then((data) => { 1952 console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); 1953}).catch((err)=>{ 1954 console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); 1955}); 1956``` 1957 1958### setOutsideTouchable<sup>7+</sup> 1959 1960setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void 1961 1962Sets whether the area outside the subwindow is touchable. This API uses an asynchronous callback to return the result. 1963 1964> **NOTE** 1965> 1966> This API cannot be used. 1967 1968**System capability**: SystemCapability.WindowManager.WindowManager.Core 1969 1970**Parameters** 1971 1972| Name | Type | Mandatory| Description | 1973| --------- | ------------------------- | ---- | ---------------- | 1974| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.| 1975| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1976 1977**Example** 1978 1979```js 1980windowClass.setOutsideTouchable(true, (err, data) => { 1981 if (err.code) { 1982 console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); 1983 return; 1984 } 1985 console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)); 1986}) 1987``` 1988 1989### setOutsideTouchable<sup>7+</sup> 1990 1991setOutsideTouchable(touchable: boolean): Promise<void> 1992 1993Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result. 1994 1995> **NOTE** 1996> 1997> This API cannot be used. 1998 1999**System capability**: SystemCapability.WindowManager.WindowManager.Core 2000 2001**Parameters** 2002 2003| Name | Type | Mandatory| Description | 2004| --------- | ------- | ---- | ---------------- | 2005| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.| 2006 2007**Return value** 2008 2009| Type | Description | 2010| ------------------- | ------------------------- | 2011| Promise<void> | Promise that returns no value.| 2012 2013**Example** 2014 2015```js 2016let promise = windowClass.setOutsideTouchable(true); 2017promise.then((data)=> { 2018 console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)); 2019}).catch((err)=>{ 2020 console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); 2021}); 2022``` 2023 2024### setPrivacyMode<sup>7+</sup> 2025 2026setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void 2027 2028Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. When in privacy mode, the window content cannot be captured or recorded. 2029 2030**System capability**: SystemCapability.WindowManager.WindowManager.Core 2031 2032**Parameters** 2033 2034| Name | Type | Mandatory| Description | 2035| ------------- | ------------------------- | ---- | -------------------- | 2036| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| 2037| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 2038 2039**Example** 2040 2041```js 2042var isPrivacyMode = true; 2043windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { 2044 if (err.code) { 2045 console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); 2046 return; 2047 } 2048 console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); 2049 2050}); 2051``` 2052 2053### setPrivacyMode<sup>7+</sup> 2054 2055setPrivacyMode(isPrivacyMode: boolean): Promise<void> 2056 2057Sets whether this window is in privacy mode. This API uses a promise to return the result. When in privacy mode, the window content cannot be captured or recorded. 2058 2059**System capability**: SystemCapability.WindowManager.WindowManager.Core 2060 2061**Parameters** 2062 2063| Name | Type | Mandatory| Description | 2064| ------------- | ------- | ---- | -------------------- | 2065| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| 2066 2067**Return value** 2068 2069| Type | Description | 2070| ------------------- | ------------------------- | 2071| Promise<void> | Promise that returns no value.| 2072 2073**Example** 2074 2075```js 2076var isPrivacyMode = true; 2077let promise = windowClass.setPrivacyMode(isPrivacyMode); 2078promise.then((data)=> { 2079 console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)); 2080}).catch((err)=>{ 2081 console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); 2082}); 2083``` 2084 2085### setTouchable<sup>7+</sup> 2086 2087setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void 2088 2089Sets whether this window is touchable. This API uses an asynchronous callback to return the result. 2090 2091**System capability**: SystemCapability.WindowManager.WindowManager.Core 2092 2093**Parameters** 2094 2095| Name | Type | Mandatory| Description | 2096| ----------- | ------------------------- | ---- | -------------------- | 2097| isTouchable | boolean | Yes | Whether the window is touchable.| 2098| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 2099 2100**Example** 2101 2102```js 2103var isTouchable = true; 2104windowClass.setTouchable(isTouchable, (err, data) => { 2105 if (err.code) { 2106 console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); 2107 return; 2108 } 2109 console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); 2110 2111}); 2112``` 2113 2114### setTouchable<sup>7+</sup> 2115 2116setTouchable(isTouchable: boolean): Promise<void> 2117 2118Sets whether this window is touchable. This API uses a promise to return the result. 2119 2120**System capability**: SystemCapability.WindowManager.WindowManager.Core 2121 2122**Parameters** 2123 2124| Name | Type | Mandatory| Description | 2125| ----------- | ------- | ---- | -------------------- | 2126| isTouchable | boolean | Yes | Whether the window is touchable.| 2127 2128**Return value** 2129 2130| Type | Description | 2131| ------------------- | ------------------------- | 2132| Promise<void> | Promise that returns no value.| 2133 2134**Example** 2135 2136```js 2137var isTouchable = true; 2138let promise = windowClass.setTouchable(isTouchable); 2139promise.then((data)=> { 2140 console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)); 2141}).catch((err)=>{ 2142 console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); 2143}); 2144``` 2145