js-apis-window.md 96.9 KB
Newer Older
W
wusongqing 已提交
1
# Window
Z
zengyawen 已提交
2

W
wusongqing 已提交
3
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
W
wusongqing 已提交
4
> 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.
W
wusongqing 已提交
5
>
Z
zengyawen 已提交
6

W
wusongqing 已提交
7
## Modules to Import
Z
zengyawen 已提交
8

G
ge-yafang 已提交
9
```js
Z
zengyawen 已提交
10 11 12
import window from '@ohos.window';
```

W
wusongqing 已提交
13
## WindowType<sup>7+</sup><a name="windowtype"></a>
W
wusongqing 已提交
14

W
wusongqing 已提交
15
Enumerates the window types.
W
wusongqing 已提交
16

W
wusongqing 已提交
17
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
18

W
wusongqing 已提交
19 20 21 22
| Name             | Default Value| Description              |
| ----------------- | ------ | ------------------ |
| TYPE_APP          | 0      | Application subwindow.  |
| TYPE_SYSTEM_ALERT | 1      | System alert window.|
Z
zengyawen 已提交
23

W
wusongqing 已提交
24 25 26 27 28 29
## AvoidAreaType<sup>7+</sup><a name="avoidareatype"></a>

Enumerates the types of the area where the window cannot be displayed.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
30 31 32 33
| Name       | Default Value| Description              |
| ----------- | ------ | ------------------ |
| TYPE_SYSTEM | 0      | Default area of the system.|
| TYPE_CUTOUT | 1      | Notch.  |
W
wusongqing 已提交
34 35 36 37 38 39 40 41 42

## WindowMode<sup>7+</sup><a name="windowmode"></a>

Enumerates the window modes of an application.

This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
43 44 45 46 47 48 49
| Name      | Default Value| Description                         |
| ---------- | ------ | ----------------------------- |
| UNDEFINED  | 1      | The window mode is not defined by the application.      |
| FULLSCREEN | 2      | The application is displayed in full screen.            |
| PRIMARY    | 3      | The application is displayed in the primary window in split-screen mode.  |
| SECONDARY  | 4      | The application is displayed in the secondary window in split-screen mode.  |
| FLOATING   | 5      | The application is displayed in a floating window.|
W
wusongqing 已提交
50 51

## SystemBarProperties<a name="systembarproperties"></a>
Z
zengyawen 已提交
52 53 54

Describes the properties of the status bar and navigation bar.

W
wusongqing 已提交
55 56
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
57 58 59 60 61 62 63 64
| Name                                  | Type| Readable| Writable| Description                                                        |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
| statusBarColor                         | string   | Yes  | Yes  | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value, for example, **\#00FF00** or **\#FF00FF00**.|
| isStatusBarLightIcon<sup>7+</sup>      | boolean  | No  | Yes  | Whether any icon on the status bar is highlighted.                                  |
| statusBarContentColor<sup>8+</sup>     | string   | No  | Yes  | Color of the text on the status bar.                                            |
| navigationBarColor                     | string   | Yes  | Yes  | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value, for example, **\#00FF00** or **\#FF00FF00**.|
| isNavigationBarLightIcon<sup>7+</sup>  | boolean  | No  | No  | Whether any icon on the navigation bar is highlighted.                                  |
| navigationBarContentColor<sup>8+</sup> | string   | No  | Yes  | Color of the text on the navigation bar.                                            |
W
wusongqing 已提交
65 66 67 68 69 70 71 72 73

## SystemBarRegionTint<sup>8+</sup><a name="systembartegiontint"></a>

Describes the callback for a single system bar.

This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
74 75 76 77 78 79 80
| Name           | Type                 | Readable| Writable| Description                                                        |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| type            | [WindowType](#windowtype) | Yes  | Yes  | Type of the system bar whose properties are changed. Only the navigation bar and status bar are supported.|
| isEnable        | boolean                   | Yes  | Yes  | Whether the system bar is displayed.                                        |
| region          | [Rect](#rect)             | Yes  | Yes  | Current position and size of the system bar.                                    |
| backgroundColor | string                    | Yes  | Yes  | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value, for example, **\#00FF00** or **\#FF00FF00**.|
| contentColor    | string                    | Yes  | Yes  | Color of the text on the system bar.                                            |
W
wusongqing 已提交
81 82 83 84 85 86 87 88 89

## SystemBarTintState<sup>8+</sup><a name="systembartintstate"></a>

Describes the callback for the current system bar.

This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
90 91 92 93
| Name      | Type                                          | Readable| Writable| Description                      |
| ---------- | -------------------------------------------------- | ---- | ---- | -------------------------- |
| displayId  | number                                             | Yes  | No  | ID of the current physical screen.          |
| regionTint | Array<[SystemBarRegionTint](#systembartegiontint)> | Yes  | Yes  | All system bar information changed.|
W
wusongqing 已提交
94 95

## Rect<sup>7+</sup><a name="rect"></a>
Z
zengyawen 已提交
96 97 98

Describes a rectangle.

W
wusongqing 已提交
99 100
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
101 102 103 104 105 106
| Name  | Type| Readable| Writable| Description              |
| ------ | -------- | ---- | ---- | ------------------ |
| left   | number   | Yes  | Yes  | Left boundary of the rectangle.|
| top    | number   | Yes  | Yes  | Top boundary of the rectangle.|
| width  | number   | Yes  | Yes  | Width of the rectangle.  |
| height | number   | Yes  | Yes  | Height of the rectangle.  |
W
wusongqing 已提交
107 108

## AvoidArea<sup>7+</sup><a name="avoidarea"></a>
Z
zengyawen 已提交
109 110 111

Describes the area where the window cannot be displayed.

W
wusongqing 已提交
112 113
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
114 115 116 117 118 119
| Name      | Type     | Readable| Writable| Description              |
| ---------- | ------------- | ---- | ---- | ------------------ |
| leftRect   | [Rect](#rect) | Yes  | Yes  | Rectangle on the left of the screen.|
| topRect    | [Rect](#rect) | Yes  | Yes  | Rectangle at the top of the screen.|
| rightRect  | [Rect](#rect) | Yes  | Yes  | Rectangle on the right of the screen.|
| bottomRect | [Rect](#rect) | Yes  | Yes  | Rectangle at the bottom of the screen.|
W
wusongqing 已提交
120 121

## Size<sup>7+</sup><a name="size"></a>
Z
zengyawen 已提交
122 123 124

Describes the window size.

W
wusongqing 已提交
125 126
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
127 128 129 130
| Name  | Type| Readable| Writable| Description      |
| ------ | -------- | ---- | ---- | ---------- |
| width  | number   | Yes  | Yes  | Window width.|
| height | number   | Yes  | Yes  | Window height.|
W
wusongqing 已提交
131 132

## WindowProperties<a name="windowproperties"></a>
Z
zengyawen 已提交
133 134 135

Describes the window properties.

W
wusongqing 已提交
136
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
137

W
wusongqing 已提交
138 139 140 141 142 143 144 145 146 147 148 149 150 151
| Name                           | Type                 | Readable| Writable| Description                                                        |
| ------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| windowRect<sup>7+</sup>         | [Rect](#rect)             | Yes  | Yes  | Window size.                                                  |
| type<sup>7+</sup>               | [WindowType](#windowtype) | Yes  | Yes  | Window type.                                                  |
| isFullScreen                    | boolean                   | Yes  | Yes  | Whether the window is displayed in full screen mode. The default value is **false**.                                     |
| 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**.                             |
| focusable<sup>7+</sup>          | boolean                   | Yes  | No  | Whether the window can gain focus. The default value is **true**.                                |
| touchable<sup>7+</sup>          | boolean                   | Yes  | No  | Whether the window is touchable. The default value is **true**.                                |
| brightness                      | number                    | Yes  | Yes  | Screen brightness. The value ranges from 0 to 1. The value **1** indicates the maximum brightness.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| 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.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| isKeepScreenOn                  | boolean                   | Yes  | Yes  | Whether the screen is always on. The default value is **false**.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| isPrivacyMode<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window is in privacy mode. The default value is **false**.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| isRoundCorner<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window has rounded corners.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| isTransparent<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window is transparent. The default value is **false**.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
W
wusongqing 已提交
152 153 154 155 156 157 158

## ColorSpace<sup>8+</sup><a name="colorspace"></a>

Describes the color gamut mode.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
159 160 161 162
| Name      | Default Value| Description          |
| ---------- | ------ | -------------- |
| DEFAULT    | 0      | Default color gamut mode.|
| WIDE_GAMUT | 1      | Wide color gamut mode.  |
W
wusongqing 已提交
163

W
wusongqing 已提交
164
## window.create<sup>7+</sup>
W
wusongqing 已提交
165 166 167 168 169

create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void

Creates a subwindow. This API uses an asynchronous callback to return the result.

W
wusongqing 已提交
170 171
This API is discarded since API version 8. You are advised to use [window.create<sup>8+</sup>](#windowcreate8) instead.

W
wusongqing 已提交
172 173 174 175
**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
176 177 178 179 180
  | Name  | Type                                  | Mandatory| Description                      |
  | -------- | -------------------------------------- | ---- | -------------------------- |
  | id       | string                                 | Yes  | Window ID.                  |
  | type     | [WindowType](#windowtype)              | Yes  | Window type.                |
  | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow created.|
W
wusongqing 已提交
181 182 183

- Example

G
ge-yafang 已提交
184
  ```js
W
wusongqing 已提交
185 186 187 188 189 190 191 192 193 194 195 196
   var windowClass = null;
   window.create("first", window.WindowType.TYPE_APP, (err, data) => {
      if (err.code) {
          console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
          return;
      }
      windowClass = data;
      console.info('SubWindow created. Data: ' + JSON.stringify(data))
      windowClass.resetSize(500, 1000);
  });
  ```

W
wusongqing 已提交
197
## window.create<sup>7+</sup>
W
wusongqing 已提交
198 199 200 201 202

create(id: string, type: WindowType): Promise&lt;Window&gt;

Creates a subwindow. This API uses a promise to return the result.

W
wusongqing 已提交
203 204
This API is discarded since API version 8. You are advised to use [window.create<sup>8+</sup>](#windowcreate8) instead.

W
wusongqing 已提交
205 206 207 208
**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
209 210 211 212
  | Name| Type                     | Mandatory| Description      |
  | ------ | ------------------------- | ---- | ---------- |
  | id     | string                    | Yes  | Window ID.  |
  | type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
213 214 215

- Return value

W
wusongqing 已提交
216 217 218
  | Type                            | Description                                             |
  | -------------------------------- | ------------------------------------------------- |
  | Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
W
wusongqing 已提交
219 220 221

- Example

G
ge-yafang 已提交
222
  ```js
W
wusongqing 已提交
223 224 225 226 227 228 229
   var windowClass = null;
   let promise = window.create("first", window.WindowType.TYPE_APP);
   promise.then((data)=> {
   	windowClass = data;
      console.info('SubWindow created. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
Z
zengyawen 已提交
230
   });
W
wusongqing 已提交
231
  ```
Z
zengyawen 已提交
232

W
wusongqing 已提交
233 234 235 236
## window.create<sup>8+</sup>

create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void

W
wusongqing 已提交
237 238 239
Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses an asynchronous callback to return the result.

Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md), starting from API version 9. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
240 241 242 243 244

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
245 246 247 248 249 250
  | Name  | Type                                  | Mandatory| Description                                                        |
  | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
  | ctx      | Context                                | Yes  | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).|
  | id       | string                                 | Yes  | Window ID.                                                    |
  | type     | [WindowType](#windowtype)              | Yes  | Window type.                                                  |
  | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the window created.                                      |
W
wusongqing 已提交
251 252 253

- Example

G
ge-yafang 已提交
254
  ```js
W
wusongqing 已提交
255 256 257 258 259 260
   var windowClass = null;
   window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
      if (err.code) {
          console.error('Failed to create the Window. Cause: ' + JSON.stringify(err));
          return;
      }
Z
zengyawen 已提交
261
      windowClass = data;
W
wusongqing 已提交
262 263 264 265
      console.info('Window created. Data: ' + JSON.stringify(data))
      windowClass.resetSize(500, 1000);
  });
  ```
Z
zengyawen 已提交
266

W
wusongqing 已提交
267
## window.create<sup>8+</sup>
E
ester.zhou 已提交
268

W
wusongqing 已提交
269
create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt;
E
ester.zhou 已提交
270

W
wusongqing 已提交
271 272 273
Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses a promise to return the result.

Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md), starting from API version 9. This API uses a promise to return the result.
W
wusongqing 已提交
274 275

**System capability**: SystemCapability.WindowManager.WindowManager.Core
E
ester.zhou 已提交
276 277 278

- Parameters

W
wusongqing 已提交
279 280 281 282 283
  | Name| Type                     | Mandatory| Description                                                        |
  | ------ | ------------------------- | ---- | ------------------------------------------------------------ |
  | ctx    | Context                   | Yes  | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).|
  | id     | string                    | Yes  | Window ID.                                                    |
  | type   | [WindowType](#windowtype) | Yes  | Window type.                                                  |
W
wusongqing 已提交
284 285

- Return value
E
ester.zhou 已提交
286

W
wusongqing 已提交
287 288 289
  | Type                            | Description                                           |
  | -------------------------------- | ----------------------------------------------- |
  | Promise&lt;[Window](#window)&gt; | Promise used to return the window created.|
E
ester.zhou 已提交
290 291

- Example
W
wusongqing 已提交
292

G
ge-yafang 已提交
293
  ```js
W
wusongqing 已提交
294 295 296 297 298 299 300 301 302 303
   var windowClass = null;
   let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT);
   promise.then((data)=> {
   	windowClass = data;
      console.info('Window created. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to create the Window. Cause: ' + JSON.stringify(err));
   });
  ```

W
wusongqing 已提交
304
## window.find<sup>7+</sup>
W
wusongqing 已提交
305 306 307 308 309 310 311 312 313

find(id: string, callback: AsyncCallback&lt;Window&gt;): void

Finds a window based on the ID. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
314 315 316 317
  | Name  | Type                                  | Mandatory| Description                        |
  | -------- | -------------------------------------- | ---- | ---------------------------- |
  | id       | string                                 | Yes  | Window ID.                    |
  | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the window found.|
W
wusongqing 已提交
318 319 320

- Example

G
ge-yafang 已提交
321
  ```js
W
wusongqing 已提交
322 323 324 325 326 327 328 329
   var windowClass = null;
   window.find("alertWindow", (err, data) => {
     if (err.code) {
         console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
         return;
     }
     windowClass = data;
     console.info('window found. Data: ' + JSON.stringify(data))
E
ester.zhou 已提交
330 331 332
  });
  ```

W
wusongqing 已提交
333
## window.find<sup>7+</sup>
Z
zengyawen 已提交
334

W
wusongqing 已提交
335
find(id: string): Promise&lt;Window&gt;
Z
zengyawen 已提交
336

W
wusongqing 已提交
337
Finds a window based on the ID. This API uses a promise to return the result.
Z
zengyawen 已提交
338

W
wusongqing 已提交
339
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
340

W
wusongqing 已提交
341 342
- Parameters

W
wusongqing 已提交
343 344 345
  | Name| Type  | Mandatory| Description    |
  | ------ | ------ | ---- | -------- |
  | id     | string | Yes  | Window ID.|
W
wusongqing 已提交
346 347 348

- Return value

W
wusongqing 已提交
349 350 351
  | Type                            | Description                                           |
  | -------------------------------- | ----------------------------------------------- |
  | Promise&lt;[Window](#window)&gt; | Promise used to return the window found.|
W
wusongqing 已提交
352 353 354

- Example

G
ge-yafang 已提交
355
  ```js
W
wusongqing 已提交
356 357 358 359 360 361 362 363 364
   var windowClass = null;
   let promise = window.find("alertWindow");
   promise.then((data)=> {
   	windowClass = data;
      console.info('window found. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
   });
  ```
Z
zengyawen 已提交
365

W
wusongqing 已提交
366
## window.getTopWindow
W
wusongqing 已提交
367 368 369 370 371 372

getTopWindow(callback: AsyncCallback&lt;Window&gt;): void

Obtains the top window of the current application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
373

E
ester.zhou 已提交
374
- Parameters
Z
zengyawen 已提交
375

W
wusongqing 已提交
376 377 378
  | Name  | Type                                  | Mandatory| Description                                  |
  | -------- | -------------------------------------- | ---- | -------------------------------------- |
  | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the top window obtained.|
Z
zengyawen 已提交
379

E
ester.zhou 已提交
380
- Example
Z
zengyawen 已提交
381

G
ge-yafang 已提交
382
  ```js
W
wusongqing 已提交
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
  var windowClass = null;
  window.getTopWindow((err, data) => {
      if (err.code) {
          console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
          return;
      }
      windowClass = data;
      console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
  });
  ```

## window.getTopWindow

getTopWindow(): Promise&lt;Window&gt;

Obtains the top window of the current application. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Return value

W
wusongqing 已提交
404 405 406
  | Type                            | Description                                                     |
  | -------------------------------- | --------------------------------------------------------- |
  | Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
407 408 409

- Example

G
ge-yafang 已提交
410
  ```js
W
wusongqing 已提交
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
   var windowClass = null;
   let promise = window.getTopWindow();
   promise.then((data)=> {
   	windowClass = data;
      console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
   })
  ```

## window.getTopWindow<sup>8+</sup>

getTopWindow(ctx: Context, callback: AsyncCallback&lt;Window&gt;): void

Obtains the top window of the current application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
431 432 433 434
  | Name  | Type                                  | Mandatory| Description                                                        |
  | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
  | ctx      | Context                                | Yes  | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).|
  | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the top window obtained.                      |
W
wusongqing 已提交
435 436 437

- Example

G
ge-yafang 已提交
438
  ```js
W
wusongqing 已提交
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
  var windowClass = null;
  window.getTopWindow(this.context, (err, data) => {
      if (err.code) {
          console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
          return;
      }
      windowClass = data;
      console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
  });
  ```

## window.getTopWindow<sup>8+</sup>

getTopWindow(ctx: Context): Promise&lt;Window&gt;

Obtains the top window of the current application. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
460 461 462
  | Name| Type   | Mandatory| Description                                                        |
  | ------ | ------- | ---- | ------------------------------------------------------------ |
  | ctx    | Context | Yes  | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).|
W
wusongqing 已提交
463 464 465

- Return value

W
wusongqing 已提交
466 467 468
  | Type                            | Description                                                     |
  | -------------------------------- | --------------------------------------------------------- |
  | Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
469 470 471

- Example

G
ge-yafang 已提交
472
  ```js
W
wusongqing 已提交
473 474 475 476 477 478 479 480 481 482 483 484 485 486
   var windowClass = null;
   let promise = window.getTopWindow(this.context);
   promise.then((data)=> {
   	windowClass = data;
      console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
   })
  ```

## on('systemBarTintChange')<sup>8+</sup>

on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): void

W
wusongqing 已提交
487
Enables listening for properties changes of the status bar and navigation bar.
W
wusongqing 已提交
488 489 490 491 492 493 494

This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
495 496 497 498
  | Name  | Type                                                     | Mandatory| Description                                                        |
  | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
  | type     | string                                                    | Yes  | Listening type.<br>Set it to **systemBarTintChange**, which indicates listening for properties changes of the status bar and navigation bar.|
  | callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
499 500 501

- Example

G
ge-yafang 已提交
502
  ```js
W
wusongqing 已提交
503
  var type = 'systemBarTintChange';
E
ester.zhou 已提交
504
  windowClass.on(type, (data) => {
W
wusongqing 已提交
505
      console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
E
ester.zhou 已提交
506 507
  });
  ```
Z
zengyawen 已提交
508

W
wusongqing 已提交
509 510 511
## off('systemBarTintChange')<sup>8+</sup>

off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;): void
Z
zengyawen 已提交
512

W
wusongqing 已提交
513
Disables listening for the properties changes of the status bar and navigation bar.
Z
zengyawen 已提交
514

W
wusongqing 已提交
515 516 517
This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
518

E
ester.zhou 已提交
519
- Parameters
Z
zengyawen 已提交
520

W
wusongqing 已提交
521 522 523 524
  | Name  | Type                                                     | Mandatory| Description                                                        |
  | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
  | type     | string                                                    | Yes  | Listening type.<br>Set it to **systemBarTintChange**, which indicates listening for properties changes of the status bar and navigation bar.|
  | callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | No  | Callback used to return the information.                                      |
Z
zengyawen 已提交
525

E
ester.zhou 已提交
526
- Example
Z
zengyawen 已提交
527

G
ge-yafang 已提交
528
  ```js
W
wusongqing 已提交
529
  var type = 'systemBarTintChange';
E
ester.zhou 已提交
530 531
  windowClass.off(type);
  ```
W
wusongqing 已提交
532 533 534

## Window

W
wusongqing 已提交
535
In 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.
W
wusongqing 已提交
536 537 538 539 540 541 542 543 544 545 546 547 548

### hide<sup>7+</sup>

hide (callback: AsyncCallback&lt;void&gt;): void

Hides this window. This API uses an asynchronous callback to return the result.

This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
549 550 551
  | Name  | Type                     | Mandatory| Description      |
  | -------- | ------------------------- | ---- | ---------- |
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
552 553 554

- Example

G
ge-yafang 已提交
555
  ```js
W
wusongqing 已提交
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
  windowClass.hide((err, data) => {
      if (err.code) {
          console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('window hidden. data: ' + JSON.stringify(data))
  })
  ```

### hide<sup>7+</sup>

hide(): Promise&lt;void&gt;

Hides this window. This API uses a promise to return the result.

This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Return value

W
wusongqing 已提交
577 578 579
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
580 581 582

- Example

G
ge-yafang 已提交
583
  ```js
W
wusongqing 已提交
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
   let promise = windowClass.hide();
   promise.then((data)=> {
      console.info('window hidden. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
   })
  ```

### show<sup>7+</sup>

show(callback: AsyncCallback&lt;void&gt;): void

Shows this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
602 603 604
  | Name  | Type                     | Mandatory| Description      |
  | -------- | ------------------------- | ---- | ---------- |
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
605 606 607

- Example

G
ge-yafang 已提交
608
  ```js
W
wusongqing 已提交
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
  windowClass.show((err, data) => {
      if (err.code) {
          console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data))
  })
  ```

### show<sup>7+</sup>

show(): Promise&lt;void&gt;

Shows this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Return value

W
wusongqing 已提交
628 629 630
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
631 632 633

- Example

G
ge-yafang 已提交
634
  ```js
W
wusongqing 已提交
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
   let promise = windowClass.show();
   promise.then((data)=> {
      console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
   })
  ```

### destroy<sup>7+</sup>

destroy(callback: AsyncCallback&lt;void&gt;): void

Destroys this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
653 654 655
  | Name  | Type                     | Mandatory| Description      |
  | -------- | ------------------------- | ---- | ---------- |
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
656 657 658

- Example

G
ge-yafang 已提交
659
  ```js
W
wusongqing 已提交
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678
  windowClass.destroy((err, data) => {
      if (err.code) {
          console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data))
  })
  ```

### destroy<sup>7+</sup>

destroy(): Promise&lt;void&gt;

Destroys this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Return value

W
wusongqing 已提交
679 680 681
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
682 683 684

- Example

G
ge-yafang 已提交
685
  ```js
W
wusongqing 已提交
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
   let promise = windowClass.destroy();
   promise.then((data)=> {
      console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
   })
  ```

### moveTo<sup>7+</sup>

moveTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void

Moves the position of this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
704 705 706 707 708
  | Name  | Type                     | Mandatory| Description                                   |
  | -------- | ------------------------- | ---- | --------------------------------------- |
  | x        | number                    | Yes  | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.|
  | y        | number                    | Yes  | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.|
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                             |
W
wusongqing 已提交
709 710 711

- Example

G
ge-yafang 已提交
712
  ```js
W
wusongqing 已提交
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
  windowClass.moveTo(300, 300, (err, data)=>{
      if (err.code) {
          console.error('Failed to move the window. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Window moved. Data: ' + JSON.stringify(data))
  
  });
  ```

### moveTo<sup>7+</sup>

moveTo(x: number, y: number): Promise&lt;void&gt;

Moves the position of this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
733 734 735 736
  | Name| Type  | Mandatory| Description                                   |
  | ------ | ------ | ---- | --------------------------------------- |
  | x      | number | Yes  | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.|
  | y      | number | Yes  | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.|
W
wusongqing 已提交
737 738 739

- Return value

W
wusongqing 已提交
740 741 742
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
743 744 745

- Example

G
ge-yafang 已提交
746
  ```js
W
wusongqing 已提交
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764
   let promise = windowClass.moveTo(300, 300);
   promise.then((data)=> {
      console.info('Window moved. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
   })
  ```

### resetSize<sup>7+</sup>

resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void

Changes the size of this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
765 766 767 768 769
  | Name  | Type                     | Mandatory| Description            |
  | -------- | ------------------------- | ---- | ---------------- |
  | width    | number                    | Yes  | New width of the window.|
  | height   | number                    | Yes  | New height of the window.|
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.      |
W
wusongqing 已提交
770 771 772

- Example

G
ge-yafang 已提交
773
  ```js
W
wusongqing 已提交
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
  windowClass.resetSize(500, 1000, (err, data) => {
      if (err.code) {
          console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Window size changed. Data: ' + JSON.stringify(data))
  });
  ```

### resetSize<sup>7+</sup>

resetSize(width: number, height: number): Promise&lt;void&gt;

Changes the size of this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
793 794 795 796
  | Name| Type  | Mandatory| Description            |
  | ------ | ------ | ---- | ---------------- |
  | width  | number | Yes  | New width of the window.|
  | height | number | Yes  | New height of the window.|
W
wusongqing 已提交
797 798 799

- Return value

W
wusongqing 已提交
800 801 802
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
803 804 805

- Example

G
ge-yafang 已提交
806
  ```js
W
wusongqing 已提交
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826
   let promise = windowClass.resetSize(500, 1000);
   promise.then((data)=> {
      console.info('Window size changed. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
   });
  ```

### setWindowType<sup>7+</sup>

setWindowType(type: WindowType, callback: AsyncCallback&lt;void&gt;): void

Sets the type of this window. This API uses an asynchronous callback to return the result.

This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
827 828 829 830
  | Name  | Type                     | Mandatory| Description      |
  | -------- | ------------------------- | ---- | ---------- |
  | type     | [WindowType](#windowtype) | Yes  | Window type.|
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
831 832 833

- Example

G
ge-yafang 已提交
834
  ```js
W
wusongqing 已提交
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856
  var type = window.TYPE_APP;
  windowClass.setWindowType(type, (err, data) => {
    if (err.code) {
        console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data))
  });
  ```

### setWindowType<sup>7+</sup>

setWindowType(type: WindowType): Promise&lt;void&gt;

Sets the type of this window. This API uses a promise to return the result.

This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
857 858 859
  | Name| Type                     | Mandatory| Description      |
  | ------ | ------------------------- | ---- | ---------- |
  | type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
860 861 862

- Return value

W
wusongqing 已提交
863 864 865
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
866 867 868

- Example

G
ge-yafang 已提交
869
  ```js
W
wusongqing 已提交
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888
   var type = window.TYPE_APP;
   let promise = windowClass.setWindowType(type);
   promise.then((data)=> {
      console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
   });
  ```

### getProperties

getProperties(callback: AsyncCallback&lt;WindowProperties&gt;): void

Obtains the properties of this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
889 890 891
  | Name  | Type                                                      | Mandatory| Description              |
  | -------- | ---------------------------------------------------------- | ---- | ------------------ |
  | callback | AsyncCallback&lt;[WindowProperties](#windowproperties)&gt; | Yes  | Callback used to return the window properties.|
W
wusongqing 已提交
892 893 894

- Example

G
ge-yafang 已提交
895
  ```js
W
wusongqing 已提交
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914
  windowClass.getProperties((err, data) => {
      if (err.code) {
          console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
  });
  ```

### getProperties

getProperties(): Promise&lt;WindowProperties&gt;

Obtains the properties of this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Return value

W
wusongqing 已提交
915 916 917
  | Type                                                | Description                                 |
  | ---------------------------------------------------- | ------------------------------------- |
  | Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise used to return the window properties.|
W
wusongqing 已提交
918 919 920

- Example

W
wusongqing 已提交
921
  ```js
W
wusongqing 已提交
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939
   let promise = windowClass.getProperties();
   promise.then((data)=> {
      console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
   });
  ```

### getAvoidArea<sup>7+</sup>

getAvoidArea(type: AvoidAreaType, callback: AsyncCallback&lt;AvoidArea&gt;): void

Obtains 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.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
940 941 942 943
  | Name  | Type                                        | Mandatory| Description                                                        |
  | -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
  | type     | [AvoidAreaType](#avoidareatype)              | Yes  | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.|
  | callback | AsyncCallback&lt;[AvoidArea](#avoidarea)&gt; | Yes  | Callback used to return the area.                                  |
W
wusongqing 已提交
944 945 946

- Example

G
ge-yafang 已提交
947
  ```js
W
wusongqing 已提交
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967
  var type = window.AvoidAreaType.TYPE_SYSTEM;
  windowClass.getAvoidArea(type, (err, data) => {
      if (err.code) {
          console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
  });
  ```

### getAvoidArea<sup>7+</sup>

getAvoidArea(type: AvoidAreaType): Promise&lt;AvoidArea&gt;

Obtains 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.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
968 969 970
  | Name| Type                           | Mandatory| Description                                                        |
  | ------ | ------------------------------- | ---- | ------------------------------------------------------------ |
  | type   | [AvoidAreaType](#avoidareatype) | Yes  | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.|
W
wusongqing 已提交
971 972 973

- Return value

W
wusongqing 已提交
974 975 976
  | Type                                  | Description                                         |
  | -------------------------------------- | --------------------------------------------- |
  | Promise&lt;[AvoidArea](#avoidarea)&gt; | Promise used to return the area.|
W
wusongqing 已提交
977 978 979

- Example

G
ge-yafang 已提交
980
  ```js
W
wusongqing 已提交
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
   let promise = windowClass.getAvoidArea();
   promise.then((data)=> {
      console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
   });
  ```

### setFullScreen

setFullScreen(isFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void

Sets whether to enable the full-screen mode for this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
999 1000 1001 1002
  | Name      | Type                     | Mandatory| Description                                          |
  | ------------ | ------------------------- | ---- | ---------------------------------------------- |
  | isFullScreen | boolean                   | Yes  | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.|
  | callback     | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                    |
W
wusongqing 已提交
1003 1004 1005

- Example

G
ge-yafang 已提交
1006
  ```js
W
wusongqing 已提交
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
  var isFullScreen = true;
  windowClass.setFullScreen(isFullScreen, (err, data) => {
      if (err.code) {
          console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data))
  });
  ```

### setFullScreen

setFullScreen(isFullScreen: boolean): Promise&lt;void&gt;

Sets whether to enable the full-screen mode for this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1027 1028 1029
  | Name      | Type   | Mandatory| Description                                          |
  | ------------ | ------- | ---- | ---------------------------------------------- |
  | isFullScreen | boolean | Yes  | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.|
W
wusongqing 已提交
1030 1031 1032

- Return value

W
wusongqing 已提交
1033 1034 1035
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1036 1037 1038

- Example

G
ge-yafang 已提交
1039
  ```js
W
wusongqing 已提交
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
  var isFullScreen = true;
  let promise = windowClass.setFullScreen(isFullScreen);
  promise.then((data)=> {
      console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
  });
  ```

### setLayoutFullScreen<sup>7+</sup>

setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void

Sets whether the window layout is in full-screen mode. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1059 1060 1061 1062
  | Name            | Type                     | Mandatory| Description                                                        |
  | ------------------ | ------------------------- | ---- | ------------------------------------------------------------ |
  | isLayoutFullScreen | boolean                   | Yes  | Whether the window layout is in full-screen mode, in which the status bar and navigation bar are displayed.|
  | callback           | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                                  |
W
wusongqing 已提交
1063 1064 1065

- Example

G
ge-yafang 已提交
1066
  ```js
W
wusongqing 已提交
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086
  var isLayoutFullScreen= true;
  windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
      if (err.code) {
          console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data))
  });
  ```

### setLayoutFullScreen<sup>7+</sup>

setLayoutFullScreen(isLayoutFullScreen: boolean): Promise&lt;void&gt;

Sets whether the window layout is in full-screen mode. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1087 1088 1089
  | Name            | Type   | Mandatory| Description                                                        |
  | ------------------ | ------- | ---- | ------------------------------------------------------------ |
  | isLayoutFullScreen | boolean | Yes  | Whether the window layout is in full-screen mode, in which the status bar and navigation bar are displayed.|
W
wusongqing 已提交
1090 1091 1092

- Return value

W
wusongqing 已提交
1093 1094 1095
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1096 1097 1098

- Example

G
ge-yafang 已提交
1099
  ```js
W
wusongqing 已提交
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118
  var isLayoutFullScreen = true;
  let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen);
  promise.then((data)=> {
      console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
  });
  ```

### setSystemBarEnable<sup>7+</sup>

setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback&lt;void&gt;): void

Sets whether to display the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1119 1120 1121 1122
  | Name  | Type                     | Mandatory| Description                                                        |
  | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
  | names    | Array                     | Yes  | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.|
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                                  |
W
wusongqing 已提交
1123 1124 1125

- Example

G
ge-yafang 已提交
1126
  ```js
W
wusongqing 已提交
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
  var names = ["status", "navigation"];
  windowClass.setSystemBarEnable(names, (err, data) => {
      if (err.code) {
          console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data))
  });
  ```

### setSystemBarEnable<sup>7+</sup>

setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;

Sets whether to display the status bar and navigation bar in this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1147 1148 1149
  | Name| Type | Mandatory| Description                                                        |
  | ------ | ----- | ---- | ------------------------------------------------------------ |
  | names  | Array | Yes  | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.|
W
wusongqing 已提交
1150 1151 1152

- Return value

W
wusongqing 已提交
1153 1154 1155
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1156 1157 1158

- Example

G
ge-yafang 已提交
1159
  ```js
W
wusongqing 已提交
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178
  var names = ["status", "navigation"];
  let promise = windowClass.setSystemBarEnable(names);
  promise.then((data)=> {
      console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
  });
  ```

### setSystemBarProperties

setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback&lt;void&gt;): void

Sets the properties of the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1179 1180 1181 1182
  | Name             | Type                                       | Mandatory| Description                |
  | ------------------- | ------------------------------------------- | ---- | -------------------- |
  | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
  | callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the execution result.          |
W
wusongqing 已提交
1183 1184 1185

- Example

G
ge-yafang 已提交
1186
  ```js
W
wusongqing 已提交
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215
  var SystemBarProperties={
      statusBarColor: '#ff00ff',
      navigationBarColor: '#00ff00',
      // The following properties are supported since API version 7.
      isStatusBarLightIcon: true,
      isNavigationBarLightIcon:false,
      // The following properties are supported since API version 8.
      statusBarContentColor:'#ffffff',
      navigationBarContentColor:'#00ffff'
  };
  windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => {
      if (err.code) {
          console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data))
  });
  ```

### setSystemBarProperties

setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&lt;void&gt;

Sets the properties of the status bar and navigation bar in this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1216 1217 1218
  | Name             | Type                                       | Mandatory| Description                |
  | ------------------- | ------------------------------------------- | ---- | -------------------- |
  | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
W
wusongqing 已提交
1219 1220 1221

- Return value

W
wusongqing 已提交
1222 1223 1224
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1225 1226 1227

- Example

G
ge-yafang 已提交
1228
  ```js
W
wusongqing 已提交
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256
  var SystemBarProperties={
      statusBarColor: '#ff00ff',
      navigationBarColor: '#00ff00',
      // The following properties are supported since API version 7.
      isStatusBarLightIcon: true,
      isNavigationBarLightIcon:false,
      // The following properties are supported since API version 8.
      statusBarContentColor:'#ffffff',
      navigationBarContentColor:'#00ffff'
  };
  let promise = windowClass.setSystemBarProperties(SystemBarProperties);
  promise.then((data)=> {
      console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
  });
  ```

### loadContent<sup>7+</sup>

loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void

Loads content to this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1257 1258 1259 1260
  | Name  | Type                     | Mandatory| Description                |
  | -------- | ------------------------- | ---- | -------------------- |
  | path     | string                    | Yes  | Path of the page from which the content will be loaded.|
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.          |
G
ge-yafang 已提交
1261

W
wusongqing 已提交
1262 1263
- Example

G
ge-yafang 已提交
1264
  ```js
W
wusongqing 已提交
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283
  windowClass.loadContent("pages/page2/page2", (err, data) => {
     if (err.code) {
           console.error('Failed to load the content. Cause:' + JSON.stringify(err));
           return;
     }
    console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
  });
  ```

### loadContent<sup>7+</sup>

loadContent(path: string): Promise&lt;void&gt;

Loads content to this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1284 1285 1286
  | Name| Type  | Mandatory| Description                |
  | ------ | ------ | ---- | -------------------- |
  | path   | string | Yes  | Path of the page from which the content will be loaded.|
G
ge-yafang 已提交
1287

W
wusongqing 已提交
1288 1289
- Return value

W
wusongqing 已提交
1290 1291 1292
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1293 1294 1295

- Example

G
ge-yafang 已提交
1296
  ```js
W
wusongqing 已提交
1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314
  let promise = windowClass.loadContent("pages/page2/page2");
  promise.then((data)=> {
      console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
  });
  ```

### isShowing<sup>7+</sup>

isShowing(callback: AsyncCallback&lt;boolean&gt;): void

Checks whether this window is displayed. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1315 1316 1317
  | Name  | Type                        | Mandatory| Description                            |
  | -------- | ---------------------------- | ---- | -------------------------------- |
  | callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return whether the window is displayed.|
W
wusongqing 已提交
1318 1319 1320

- Example

G
ge-yafang 已提交
1321
  ```js
W
wusongqing 已提交
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340
  windowClass.isShowing((err, data) => {
      if (err.code) {
          console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data))
  });
  ```

### isShowing<sup>7+</sup>

isShowing(): Promise&lt;boolean&gt;

Checks whether this window is displayed. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Return value

W
wusongqing 已提交
1341 1342 1343
  | Type                  | Description                                                 |
  | ---------------------- | ----------------------------------------------------- |
  | Promise&lt;boolean&gt; | Promise used to return whether the window is displayed.|
W
wusongqing 已提交
1344 1345 1346

- Example

G
ge-yafang 已提交
1347
  ```js
W
wusongqing 已提交
1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365
  let promise = windowClass.isShowing();
  promise.then((data)=> {
      console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
  });
  ```

### on('windowSizeChange')<sup>7+</sup>

on(type:  'windowSizeChange', callback: Callback&lt;Size&gt;): void

Enables listening for window size changes.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1366 1367 1368 1369
  | Name  | Type                         | Mandatory| Description                                                        |
  | -------- | ----------------------------- | ---- | ------------------------------------------------------------ |
  | type     | string                        | Yes  | Listening type.<br>Set it to **windowSizeChange**, which indicates listening for window size changes.|
  | callback | Callback&lt;[Size](#size)&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
1370 1371 1372

- Example

G
ge-yafang 已提交
1373
  ```js
W
wusongqing 已提交
1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389
  var type = 'windowSizeChange';
  windowClass.on(type, (data) => {
      console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
  });
  ```

### off('windowSizeChange')<sup>7+</sup>

off(type: 'windowSizeChange', callback?: Callback&lt;Size &gt;): void

Disables listening for window size changes.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1390 1391 1392 1393
  | Name  | Type                         | Mandatory| Description                                                        |
  | -------- | ----------------------------- | ---- | ------------------------------------------------------------ |
  | type     | string                        | Yes  | Listening type.<br>Set it to **windowSizeChange<sup>7+</sup>**, which indicates listening for window size changes.|
  | callback | Callback&lt;[Size](#size)&gt; | No  | Callback used to return the information.                                      |
W
wusongqing 已提交
1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411

- Example

  ```
  var type = 'windowSizeChange';
  windowClass.off(type);
  ```

### on('systemAvoidAreaChange')<sup>7+</sup>

on(type: 'systemAvoidAreaChange', callback: Callback&lt;AvoidArea&gt;): void

Enables listening for changes to the area where the window cannot be displayed.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1412 1413 1414 1415
  | Name  | Type                                   | Mandatory| Description                                                        |
  | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
  | type     | string                                  | Yes  | Listening type.<br>Set it to **systemAvoidAreaChange**, which indicates listening for changes to the area where the window cannot be displayed.|
  | callback | Callback&lt;[AvoidArea](#avoidarea)&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
1416 1417 1418

- Example

G
ge-yafang 已提交
1419
  ```js
W
wusongqing 已提交
1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435
  var type = 'systemAvoidAreaChange';
  windowClass.on(type, (data) => {
      console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
  });
  ```

### off('systemAvoidAreaChange')<sup>7+</sup>

off(type: 'systemAvoidAreaChange', callback?: Callback&lt;AvoidArea&gt;): void

Disables listening for changes to the area where the window cannot be displayed.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1436 1437 1438 1439
  | Name  | Type                                   | Mandatory| Description                                                        |
  | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
  | type     | string                                  | Yes  | Listening type.<br>Set it to **systemAvoidAreaChange**, which indicates listening for changes to the area where the window cannot be displayed.|
  | callback | Callback&lt;[AvoidArea](#avoidarea)&gt; | No  | Callback used to return the information.                                      |
W
wusongqing 已提交
1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459

- Example

  ```
  var type = 'systemAvoidAreaChange';
  windowClass.off(type);
  ```

### on('keyboardHeightChange')<sup>7+</sup>

on(type: 'keyboardHeightChange', callback: Callback&lt;number&gt;): void

Enables listening for keyboard height changes.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1460 1461 1462 1463
  | Name  | Type              | Mandatory| Description                                                        |
  | -------- | ------------------ | ---- | ------------------------------------------------------------ |
  | type     | string             | Yes  | Listening type.<br>Set it to **keyboardHeightChange**, which indicates listening for keyboard height changes.|
  | callback | Callbacknumber&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
1464 1465 1466

- Example

G
ge-yafang 已提交
1467
  ```js
W
wusongqing 已提交
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485
  var type = 'keyboardHeightChange';
  windowClass.on(type, (data) => {
      console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
  });
  ```

### off('keyboardHeightChange')<sup>7+</sup>

off(type: 'keyboardHeightChange', callback?: Callback&lt;number&gt;): void

Disables listening for keyboard height changes.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1486 1487 1488 1489
  | Name  | Type                  | Mandatory| Description                                                        |
  | -------- | ---------------------- | ---- | ------------------------------------------------------------ |
  | type     | string                 | Yes  | Listening type.<br>Set it to **keyboardHeightChange**, which indicates listening for keyboard height changes.|
  | callback | Callback&lt;number&gt; | No  | Callback used to return the information.                                      |
W
wusongqing 已提交
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507

- Example

  ```
  var type = 'keyboardHeightChange';
  windowClass.off(type);
  ```

### isSupportWideGamut<sup>8+</sup>

isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void

Checks whether this window supports the wide color gamut mode. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1508 1509 1510
  | Name  | Type                        | Mandatory| Description                            |
  | -------- | ---------------------------- | ---- | -------------------------------- |
  | callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return whether the wide color gamut mode is supported.|
W
wusongqing 已提交
1511 1512 1513

- Example

G
ge-yafang 已提交
1514
  ```js
W
wusongqing 已提交
1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533
  windowClass.isSupportWideGamut((err, data) => {
      if (err.code) {
          console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data))
  })
  ```

### isSupportWideGamut<sup>8+</sup>

isSupportWideGamut(): Promise&lt;boolean&gt;

Checks whether this window supports the wide color gamut mode. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Return value

W
wusongqing 已提交
1534
  | Type                  | Description                                                        |
W
wusongqing 已提交
1535
  | ---------------------- | ------------------------------------------------------------ |
W
wusongqing 已提交
1536
  | Promise&lt;boolean&gt; | Promise used to return whether the wide color gamut mode is supported.|
W
wusongqing 已提交
1537 1538 1539

- Example

W
wusongqing 已提交
1540
  ```
W
wusongqing 已提交
1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558
  let promise = windowClass.isSupportWideGamut();
  promise.then((data)=> {
      console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
  });
  ```

### setColorSpace<sup>8+</sup>

setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void

Sets this window to the wide or default color gamut mode. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1559 1560 1561 1562
  | Name    | Type                     | Mandatory| Description        |
  | ---------- | ------------------------- | ---- | ------------ |
  | colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
  | callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.  |
W
wusongqing 已提交
1563 1564 1565

- Example

G
ge-yafang 已提交
1566
  ```js
W
wusongqing 已提交
1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585
  windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => {
      if (err.code) {
          console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data))
  })
  ```

### setColorSpace<sup>8+</sup>

setColorSpace(colorSpace:ColorSpace): Promise&lt;void&gt;

Sets this window to the wide or default color gamut mode. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1586 1587 1588
  | Name    | Type                     | Mandatory| Description        |
  | ---------- | ------------------------- | ---- | ------------ |
  | colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
W
wusongqing 已提交
1589 1590 1591

- Return value

W
wusongqing 已提交
1592 1593 1594
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1595 1596 1597

- Example

G
ge-yafang 已提交
1598
  ```js
W
wusongqing 已提交
1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616
  let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT);
  promise.then((data)=> {
      console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err));
  });
  ```

### getColorSpace<sup>8+</sup>

getColorSpace(callback: AsyncCallback&lt;ColorSpace&gt;): void

Obtains the color gamut mode of this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1617 1618 1619
  | Name  | Type                                          | Mandatory| Description                      |
  | -------- | ---------------------------------------------- | ---- | -------------------------- |
  | callback | AsyncCallback&lt;[ColorSpace](#colorspace)&gt; | Yes  | Callback used to return the color gamut mode obtained.|
W
wusongqing 已提交
1620 1621 1622

- Example

G
ge-yafang 已提交
1623
  ```js
W
wusongqing 已提交
1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642
  windowClass.getColorSpace((err, data) => {
      if (err.code) {
          console.error('Failed to get window color space. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data))
  })
  ```

### getColorSpace<sup>8+</sup>

getColorSpace(): Promise&lt;ColorSpace&gt;

Obtains the color gamut mode of this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Return value

W
wusongqing 已提交
1643 1644 1645
  | Type                                    | Description                                     |
  | ---------------------------------------- | ----------------------------------------- |
  | Promise&lt;[ColorSpace](#colorspace)&gt; | Promise used to return the color gamut mode obtained.|
W
wusongqing 已提交
1646 1647 1648

- Example

G
ge-yafang 已提交
1649
  ```js
W
wusongqing 已提交
1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669
  let promise = windowClass.getColorSpace();
  promise.then((data)=> {
      console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err));
  });
  ```

### setBackgroundColor

setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void

Sets the background color for this window. This API uses an asynchronous callback to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1670 1671 1672 1673
  | Name  | Type                     | Mandatory| Description                                                        |
  | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
  | color    | string                    | Yes  | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.|
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                                  |
W
wusongqing 已提交
1674 1675 1676

- Example

G
ge-yafang 已提交
1677
  ```js
W
wusongqing 已提交
1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699
  var color = '#00ff33';
  windowClass.setBackgroundColor(color, (err, data) => {
      if (err.code) {
          console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
  });
  ```

### setBackgroundColor

setBackgroundColor(color: string): Promise&lt;void&gt;

Sets the background color for this window. This API uses a promise to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1700 1701 1702
  | Name| Type  | Mandatory| Description                                                        |
  | ------ | ------ | ---- | ------------------------------------------------------------ |
  | color  | string | Yes  | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.|
W
wusongqing 已提交
1703 1704 1705

- Return value

W
wusongqing 已提交
1706 1707 1708
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1709 1710 1711

- Example

G
ge-yafang 已提交
1712
  ```js
W
wusongqing 已提交
1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733
  var color = '#00ff33';
  let promise = windowClass.setBackgroundColor(color);
  promise.then((data)=> {
      console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
  });
  ```

### setBrightness

setBrightness(brightness: number, callback: AsyncCallback&lt;void&gt;): void

Sets the screen brightness for this window. This API uses an asynchronous callback to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1734 1735 1736 1737
  | Name    | Type                     | Mandatory| Description                                |
  | ---------- | ------------------------- | ---- | ------------------------------------ |
  | brightness | number                    | Yes  | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.|
  | callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                          |
W
wusongqing 已提交
1738 1739 1740

- Example

G
ge-yafang 已提交
1741
  ```js
W
wusongqing 已提交
1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763
  var brightness = 1;
  windowClass.setBrightness(brightness, (err, data) => {
      if (err.code) {
          console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
  });
  ```

### setBrightness

setBrightness(brightness: number): Promise&lt;void&gt;

Sets the screen brightness for this window. This API uses a promise to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1764 1765 1766
  | Name    | Type  | Mandatory| Description                                |
  | ---------- | ------ | ---- | ------------------------------------ |
  | brightness | number | Yes  | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.|
W
wusongqing 已提交
1767 1768 1769

- Return value

W
wusongqing 已提交
1770 1771 1772
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1773 1774 1775

- Example

G
ge-yafang 已提交
1776
  ```js
W
wusongqing 已提交
1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797
  var brightness = 1;
  let promise = windowClass.setBrightness(brightness);
  promise.then((data)=> {
      console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
  });
  ```

### setDimBehind<sup>7+</sup>

setDimBehind(dimBehindValue: number, callback: AsyncCallback&lt;void&gt;): void

Sets the dimness of the window that is not on top. This API uses an asynchronous callback to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1798 1799 1800 1801
  | Name        | Type                     | Mandatory| Description                                              |
  | -------------- | ------------------------- | ---- | -------------------------------------------------- |
  | dimBehindValue | number                    | Yes  | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.|
  | callback       | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                        |
W
wusongqing 已提交
1802 1803 1804

- Example

G
ge-yafang 已提交
1805
  ```js
W
wusongqing 已提交
1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826
  windowClass.setDimBehind(0.5, (err, data) => {
      if (err.code) {
          console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data));
  });
  ```

### setDimBehind<sup>7+</sup>

setDimBehind(dimBehindValue: number): Promise&lt;void&gt;

Sets the dimness of the window that is not on top. This API uses a promise to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1827 1828 1829
  | Name        | Type  | Mandatory| Description                                              |
  | -------------- | ------ | ---- | -------------------------------------------------- |
  | dimBehindValue | number | Yes  | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.|
W
wusongqing 已提交
1830 1831 1832

- Return value

W
wusongqing 已提交
1833 1834 1835
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1836 1837 1838

- Example

G
ge-yafang 已提交
1839
  ```js
W
wusongqing 已提交
1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859
  let promise = windowClass.setDimBehind(0.5);
  promise.then((data)=> {
      console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
  });
  ```

### setFocusable<sup>7+</sup>

setFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void

Sets whether this window can gain focus. This API uses an asynchronous callback to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1860 1861 1862 1863
  | Name     | Type                     | Mandatory| Description                        |
  | ----------- | ------------------------- | ---- | ---------------------------- |
  | isFocusable | boolean                   | Yes  | Whether the window can gain focus.|
  | callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                  |
W
wusongqing 已提交
1864 1865 1866

- Example

G
ge-yafang 已提交
1867
  ```js
W
wusongqing 已提交
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889
  var isFocusable= true;
  windowClass.setFocusable(isFocusable, (err, data) => {
      if (err.code) {
          console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
  });
  ```

### setFocusable<sup>7+</sup>

setFocusable(isFocusable: boolean): Promise&lt;void&gt;

Sets whether this window can gain focus. This API uses a promise to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1890 1891 1892
  | Name     | Type   | Mandatory| Description                        |
  | ----------- | ------- | ---- | ---------------------------- |
  | isFocusable | boolean | Yes  | Whether the window can gain focus.|
W
wusongqing 已提交
1893 1894 1895

- Return value

W
wusongqing 已提交
1896 1897 1898
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1899 1900 1901

- Example

G
ge-yafang 已提交
1902
  ```js
W
wusongqing 已提交
1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923
  var isFocusable= true;
  let promise = windowClass.setFocusable(isFocusable);
  promise.then((data)=> {
      console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
  });
  ```

### setKeepScreenOn

setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback&lt;void&gt;): void

Sets whether to keep the screen always on. This API uses an asynchronous callback to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1924 1925 1926 1927
  | Name        | Type                     | Mandatory| Description                    |
  | -------------- | ------------------------- | ---- | ------------------------ |
  | isKeepScreenOn | boolean                   | Yes  | Whether to keep the screen always on.|
  | callback       | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.              |
W
wusongqing 已提交
1928 1929 1930

- Example

G
ge-yafang 已提交
1931
  ```js
W
wusongqing 已提交
1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953
  var isKeepScreenOn = true;
  windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
      if (err.code) {
          console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
  });
  ```

### setKeepScreenOn

setKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;

Sets whether to keep the screen always on. This API uses a promise to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1954 1955 1956
  | Name        | Type   | Mandatory| Description                    |
  | -------------- | ------- | ---- | ------------------------ |
  | isKeepScreenOn | boolean | Yes  | Whether to keep the screen always on.|
W
wusongqing 已提交
1957 1958 1959

- Return value

W
wusongqing 已提交
1960 1961 1962
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1963 1964 1965

- Example

G
ge-yafang 已提交
1966
  ```js
W
wusongqing 已提交
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987
  var isKeepScreenOn= true;
  let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
  promise.then((data)=> {
      console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
  });
  ```

### setOutsideTouchable<sup>7+</sup>

setOutsideTouchable(touchable: boolean, callback: AsyncCallback&lt;void&gt;): void

Sets whether the area outside the subwindow is touchable. This API uses an asynchronous callback to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
1988 1989 1990 1991
  | Name   | Type                     | Mandatory| Description            |
  | --------- | ------------------------- | ---- | ---------------- |
  | 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.|
  | callback  | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.      |
W
wusongqing 已提交
1992 1993 1994

- Example

G
ge-yafang 已提交
1995
  ```js
W
wusongqing 已提交
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016
  windowClass.setOutsideTouchable(true, (err, data) => {
      if (err.code) {
          console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data))
  })
  ```

### setOutsideTouchable<sup>7+</sup>

setOutsideTouchable(touchable: boolean): Promise&lt;void&gt;

Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
2017 2018 2019
  | Name   | Type   | Mandatory| Description            |
  | --------- | ------- | ---- | ---------------- |
  | 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.|
W
wusongqing 已提交
2020 2021 2022

- Return value

W
wusongqing 已提交
2023 2024 2025
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2026 2027 2028

- Example

G
ge-yafang 已提交
2029
  ```js
W
wusongqing 已提交
2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049
  let promise = windowClass.setOutsideTouchable(true);
  promise.then((data)=> {
      console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
  });
  ```

### setPrivacyMode<sup>7+</sup>

setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): void

Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
2050 2051 2052 2053
  | Name       | Type                     | Mandatory| Description                |
  | ------------- | ------------------------- | ---- | -------------------- |
  | isPrivacyMode | boolean                   | Yes  | Whether the window is in privacy mode.|
  | callback      | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.          |
W
wusongqing 已提交
2054 2055 2056

- Example

G
ge-yafang 已提交
2057
  ```js
W
wusongqing 已提交
2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080
  var isPrivacyMode = true;
  windowClass.setPrivacyMode(isPrivacyMode, (err, data) => {
      if (err.code) {
          console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data));
  
  });
  ```

### setPrivacyMode<sup>7+</sup>

setPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt;

Sets whether this window is in privacy mode. This API uses a promise to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
2081 2082 2083
  | Name       | Type   | Mandatory| Description                |
  | ------------- | ------- | ---- | -------------------- |
  | isPrivacyMode | boolean | Yes  | Whether the window is in privacy mode.|
W
wusongqing 已提交
2084 2085 2086

- Return value

W
wusongqing 已提交
2087 2088 2089
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2090 2091 2092

- Example

G
ge-yafang 已提交
2093
  ```js
W
wusongqing 已提交
2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114
  var isPrivacyMode = true;
  let promise = windowClass.setPrivacyMode(isPrivacyMode);
  promise.then((data)=> {
      console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
  });
  ```

### setTouchable<sup>7+</sup>

setTouchable(isTouchable: boolean, callback: AsyncCallback&lt;void&gt;): void

Sets whether this window is touchable. This API uses an asynchronous callback to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
2115 2116 2117 2118
  | Name     | Type                     | Mandatory| Description                |
  | ----------- | ------------------------- | ---- | -------------------- |
  | isTouchable | boolean                   | Yes  | Whether the window is touchable.|
  | callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.          |
W
wusongqing 已提交
2119 2120 2121

- Example

G
ge-yafang 已提交
2122
  ```js
W
wusongqing 已提交
2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145
  var isTouchable = true;
  windowClass.setTouchable(isTouchable, (err, data) => {
      if (err.code) {
          console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));
  
  });
  ```

### setTouchable<sup>7+</sup>

setTouchable(isTouchable: boolean): Promise&lt;void&gt;

Sets whether this window is touchable. This API uses a promise to return the result.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
2146 2147 2148
  | Name     | Type   | Mandatory| Description                |
  | ----------- | ------- | ---- | -------------------- |
  | isTouchable | boolean | Yes  | Whether the window is touchable.|
W
wusongqing 已提交
2149 2150 2151

- Return value

W
wusongqing 已提交
2152 2153 2154
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2155 2156 2157

- Example

G
ge-yafang 已提交
2158
  ```js
W
wusongqing 已提交
2159 2160 2161 2162 2163 2164 2165 2166 2167
  var isTouchable = true;
  let promise = windowClass.setTouchable(isTouchable);
  promise.then((data)=> {
      console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
  });
  ```

W
wusongqing 已提交
2168 2169 2170 2171 2172 2173
## WindowStageEventType<sup>9+</sup><a name="windowstageeventtype9"></a>

Describes the lifecycle of a window stage.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2174 2175 2176 2177 2178 2179
| Name      | Default Value| Description    |
| ---------- | ------ | -------- |
| FOREGROUND | 1      | The window stage is running in the foreground.|
| ACTIVE     | 2      | The window stage gains focus.|
| INACTIVE   | 3      | The window stage loses focus.|
| BACKGROUND | 4      | The window stage is running in the background.|
W
wusongqing 已提交
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194

## WindowStage<sup>9+</sup>

Before calling any of the following APIs, you must use `[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)` to create a **WindowStage** instance.

### getMainWindow<sup>9+</sup>

getMainWindow(): Promise&lt;Window&gt;

Obtains the main window of this window stage. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Return value

W
wusongqing 已提交
2195 2196 2197
  | Type                            | Description                                                      |
  | -------------------------------- | ---------------------------------------------------------- |
  | Promise&lt;[Window](#window)&gt; | Promise used to return the main window.|
W
wusongqing 已提交
2198 2199 2200

- Example

G
ge-yafang 已提交
2201
  ```ts
W
wusongqing 已提交
2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var windowClass = null;
          let promise = windowStage.getMainWindow();
          promise.then((data)=> {
          windowClass = data;
              console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data))
          }).catch((err)=>{
              console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
          });
      }
  }
  ```

### getMainWindow<sup>9+</sup>

getMainWindow(callback: AsyncCallback&lt;Window&gt;): void

Obtains the main window of this window stage. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
2227 2228 2229
  | Name  | Type                                  | Mandatory| Description                                   |
  | -------- | -------------------------------------- | ---- | --------------------------------------- |
  | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the main window.|
W
wusongqing 已提交
2230 2231 2232

- Example

G
ge-yafang 已提交
2233
  ```ts
W
wusongqing 已提交
2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var windowClass = null;
          windowStage.getMainWindow((err, data) => {
              if (err.code) {
                  console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
                  return;
              }
              windowClass = data;
              console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
          });
      }
  }
  ```

### createSubWindow<sup>9+</sup>

createSubWindow(name: string): Promise&lt;Window&gt;

Creates a subwindow for this window stage. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
2257

W
wusongqing 已提交
2258 2259
- Parameters

W
wusongqing 已提交
2260 2261 2262
  | Name| Type  | Mandatory| Description          |
  | ------ | ------ | ---- | -------------- |
  | name   | String | Yes  | Name of the subwindow.|
G
ge-yafang 已提交
2263

W
wusongqing 已提交
2264 2265
- Return value

W
wusongqing 已提交
2266 2267 2268
  | Type                            | Description                                             |
  | -------------------------------- | ------------------------------------------------- |
  | Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
G
ge-yafang 已提交
2269

W
wusongqing 已提交
2270 2271
- Example

G
ge-yafang 已提交
2272
  ```ts
W
wusongqing 已提交
2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var windowClass = null;
          let promise = windowStage.createSubWindow("mySubWindow");
          promise.then((data)=> {
              windowClass = data;
              console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data))
          }).catch((err)=>{
              console.error('Failed to create sub window. Cause: ' + JSON.stringify(err));
          })
      }
  }
  ```

### createSubWindow<sup>9+</sup>

createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void

Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

- Parameters

W
wusongqing 已提交
2298 2299 2300 2301
  | Name  | Type                                  | Mandatory| Description                          |
  | -------- | -------------------------------------- | ---- | ------------------------------ |
  | name     | String                                 | Yes  | Name of the subwindow.                |
  | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow created.|
W
wusongqing 已提交
2302 2303 2304

- Example

G
ge-yafang 已提交
2305
  ```ts
W
wusongqing 已提交
2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var windowClass = null;
          windowStage.createSubWindow("mySubWindow", (err, data) => {
              if (err.code) {
                  console.error('Failed to create sub window. Cause: ' + JSON.stringify(err));
                  return;
              }
              windowClass = data;
              console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data));
              windowClass.resetSize(500, 1000);
          });
      }
  }
  ```

### getSubWindow<sup>9+</sup>

getSubWindow(): Promise&lt;Array&lt;Window&gt;&gt;

Obtains all the subwindows of this window stage. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
2330

W
wusongqing 已提交
2331 2332
- Return value

W
wusongqing 已提交
2333 2334 2335
  | Type                                         | Description                                                        |
  | --------------------------------------------- | ------------------------------------------------------------ |
  | Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.|
W
wusongqing 已提交
2336 2337 2338

- Example

G
ge-yafang 已提交
2339
  ```ts
W
wusongqing 已提交
2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var windowClass = null;
          let promise = windowStage.getSubWindow();
          promise.then((data)=> {
              windowClass = data;
              console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data))
          }).catch((err)=>{
              console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err));
          })
      }
  }
  ```

### getSubWindow<sup>9+</sup>

getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void

Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
2362

W
wusongqing 已提交
2363 2364
- Parameters

W
wusongqing 已提交
2365 2366 2367
  | Name  | Type                                               | Mandatory| Description                                       |
  | -------- | --------------------------------------------------- | ---- | ------------------------------------------- |
  | callback | AsyncCallback&lt;Array&lt;[Window](#window)&gt;&gt; | Yes  | Callback used to return all the subwindows.|
W
wusongqing 已提交
2368 2369 2370

- Example

G
ge-yafang 已提交
2371
  ```ts
W
wusongqing 已提交
2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var windowClass = null;
          windowStage.getSubWindow((err, data) => {
              if (err.code) {
                  console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err));
                  return;
              }
              windowClass = data;
              console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data));
          });
      }
  }
  ```

### loadContent<sup>9+</sup>

loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void

Loads content to this window stage. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value 'windowSizeChange'

- Parameters

W
wusongqing 已提交
2398 2399 2400 2401
  | Name  | Type                     | Mandatory| Description                |
  | -------- | ------------------------- | ---- | -------------------- |
  | path     | string                    | Yes  | Path of the page from which the content will be loaded.|
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.          |
G
ge-yafang 已提交
2402

W
wusongqing 已提交
2403 2404
- Example

G
ge-yafang 已提交
2405
  ```ts
W
wusongqing 已提交
2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          windowStage.loadContent("pages/page2", (err, data) => {
              if (err.code) {
                  console.error('Failed to load the content. Cause:' + JSON.stringify(err));
                  return;
              }
              console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
          });
      }
  }
  ```
G
ge-yafang 已提交
2419

W
wusongqing 已提交
2420 2421 2422 2423 2424 2425 2426
### on('windowStageEvent')<sup>9+</sup>

on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void

Enables listening for window stage lifecycle changes.

**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
2427

W
wusongqing 已提交
2428 2429
- Parameters

W
wusongqing 已提交
2430 2431 2432 2433
  | Name  | Type                                                        | Mandatory| Description                                                        |
  | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
  | type     | string                                                       | Yes  | Listening type.<br>Set it to **windowStageEvent**, which indicates listening for window stage lifecycle changes.|
  | callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
2434 2435 2436

- Example

G
ge-yafang 已提交
2437
  ```ts
W
wusongqing 已提交
2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var type = 'windowStageEvent';
          windowStage.on(type, (data) => {
              console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data));
          });
      }
  }
  ```

### off('windowStageEvent')<sup>9+</sup>

off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&gt;): void

Disables listening for window stage lifecycle changes.

**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
2456

W
wusongqing 已提交
2457 2458
- Parameters

W
wusongqing 已提交
2459 2460 2461 2462
  | Name  | Type                                                        | Mandatory| Description                                                        |
  | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
  | type     | string                                                       | Yes  | Listening type.<br>Set it to **windowStageEvent**, which indicates listening for window stage lifecycle changes.|
  | callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | No  | Callback used to return the information.                                      |
G
ge-yafang 已提交
2463

W
wusongqing 已提交
2464 2465
- Example

G
ge-yafang 已提交
2466
  ```ts
W
wusongqing 已提交
2467 2468 2469 2470 2471 2472 2473 2474
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var type = 'windowStageEvent';
          windowStage.off(type);
      }
  }
  ```