提交 b928786f 编写于 作者: G Gloria

Update docs against 11213+10885+11375+11555+11699+11754+11874

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 7224a63f
...@@ -56,7 +56,7 @@ An asynchronous callback is used when a system window is created in the case tha ...@@ -56,7 +56,7 @@ An asynchronous callback is used when a system window is created in the case tha
| ---------- | -------------------------- | -- | ----------------------------------- | | ---------- | -------------------------- | -- | ----------------------------------- |
| name | string | Yes| Name of the subwindow. | | name | string | Yes| Name of the subwindow. |
| windowType | [WindowType](#windowtype7) | Yes| Type of the subwindow. | | windowType | [WindowType](#windowtype7) | Yes| Type of the subwindow. |
| ctx | BaseContext | No| Current application context.<br>For details about the context in the FA model, see [Context](js-apis-Context.md).<br>For details about the context in the stage model, see [Context](js-apis-service-extension-context.md).<br>If this parameter is not set, no context is used. | | ctx | BaseContext | No| Current application context.<br>For details about the context in the FA model, see [Context](js-apis-Context.md).<br>For details about the context in the stage model, see [Context](js-apis-service-extension-context.md).<br> If this parameter is not set, no context is used. |
| displayId | number | No| ID of the current physical screen. If this parameter is not set, the default value **-1** is used.| | displayId | number | No| ID of the current physical screen. If this parameter is not set, the default value **-1** is used.|
| parentId | number | No| ID of the parent window. If this parameter is not set, the default value **-1** is used. | | parentId | number | No| ID of the parent window. If this parameter is not set, the default value **-1** is used. |
...@@ -108,14 +108,14 @@ Describes the properties of the status bar and navigation bar. ...@@ -108,14 +108,14 @@ Describes the properties of the status bar and navigation bar.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type| Readable| Writable| Mandatory| Description | | Name | Type| Mandatory| Description |
| -------------------------------------- | -------- | ---- | ---- | ---- | ------------------------------------------------------------ | | -------------------------------------- | -------- | ---- | ------------------------------------------------------------ |
| statusBarColor | string | No | Yes | No | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**. The default value is **#0x66000000**.| | statusBarColor | string | No | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**. The default value is **#0x66000000**.|
| isStatusBarLightIcon<sup>7+</sup> | boolean | No | Yes | No | Whether any icon on the status bar is highlighted. The value **true** means that the icon is highlighted, and **false** means the opposite. The default value is **false**.| | isStatusBarLightIcon<sup>7+</sup> | boolean | No | Whether any icon on the status bar is highlighted. The value **true** means that the icon is highlighted, and **false** means the opposite. The default value is **false**.|
| statusBarContentColor<sup>8+</sup> | string | No | Yes | No | Color of the text on the status bar. After this property is set, the setting of **isStatusBarLightIcon** is invalid. The default value is **0xE5FFFFFF**.| | statusBarContentColor<sup>8+</sup> | string | No | Color of the text on the status bar. After this property is set, the setting of **isStatusBarLightIcon** is invalid. The default value is **0xE5FFFFFF**.|
| navigationBarColor | string | No | Yes | No | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**. The default value is **#0x66000000**.| | navigationBarColor | string | No | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**. The default value is **#0x66000000**.|
| isNavigationBarLightIcon<sup>7+</sup> | boolean | No | Yes | No | Whether any icon on the navigation bar is highlighted. The value **true** means that the icon is highlighted, and **false** means the opposite. The default value is **false**.| | isNavigationBarLightIcon<sup>7+</sup> | boolean | No | Whether any icon on the navigation bar is highlighted. The value **true** means that the icon is highlighted, and **false** means the opposite. The default value is **false**.|
| navigationBarContentColor<sup>8+</sup> | string | No | Yes | No | Color of the text on the navigation bar. After this property is set, the setting of **isNavigationBarLightIcon** is invalid. The default value is **0xE5FFFFFF**.| | navigationBarContentColor<sup>8+</sup> | string | No | Color of the text on the navigation bar. After this property is set, the setting of **isNavigationBarLightIcon** is invalid. The default value is **0xE5FFFFFF**.|
## Orientation<sup>9+</sup> ## Orientation<sup>9+</sup>
...@@ -248,7 +248,7 @@ Enumerates the color spaces. ...@@ -248,7 +248,7 @@ Enumerates the color spaces.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Default Value | Description | | Name | Value| Description |
| ---------- | ------ | -------------- | | ---------- | ------ | -------------- |
| DEFAULT | 0 | Default gamut.| | DEFAULT | 0 | Default gamut.|
| WIDE_GAMUT | 1 | Wide-gamut. | | WIDE_GAMUT | 1 | Wide-gamut. |
...@@ -339,7 +339,7 @@ try { ...@@ -339,7 +339,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.createWindow<sup>9+</sup> ## window.createWindow<sup>9+</sup>
...@@ -386,7 +386,7 @@ try { ...@@ -386,7 +386,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.findWindow<sup>9+</sup> ## window.findWindow<sup>9+</sup>
...@@ -412,11 +412,12 @@ Finds a window based on the ID. ...@@ -412,11 +412,12 @@ Finds a window based on the ID.
**Example** **Example**
```js ```js
let windowClass = null;
try { try {
let windowClass = window.findWindow('alertWindow'); windowClass = window.findWindow('alertWindow');
} catch (exception) { } catch (exception) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception)); console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.getLastWindow<sup>9+</sup> ## window.getLastWindow<sup>9+</sup>
...@@ -458,7 +459,7 @@ try { ...@@ -458,7 +459,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.getLastWindow<sup>9+</sup> ## window.getLastWindow<sup>9+</sup>
...@@ -504,7 +505,7 @@ try { ...@@ -504,7 +505,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.minimizeAll<sup>9+</sup> ## window.minimizeAll<sup>9+</sup>
...@@ -535,16 +536,12 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -535,16 +536,12 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```js ```js
import display from '@ohos.display' import display from '@ohos.display'
import window from '@ohos.window'
let displayClass = null;
try { try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
try { try {
window.minimizeAll(displayClass.id, (err) => { window.minimizeAll(displayClass.id, (err) => {
if(err.code) { if(err.code) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
...@@ -552,9 +549,12 @@ try { ...@@ -552,9 +549,12 @@ try {
} }
console.info('Succeeded in minimizing all windows.'); console.info('Succeeded in minimizing all windows.');
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
}; }
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
## window.minimizeAll<sup>9+</sup> ## window.minimizeAll<sup>9+</sup>
...@@ -590,26 +590,24 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -590,26 +590,24 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```js ```js
import display from '@ohos.display' import display from '@ohos.display'
import window from '@ohos.window'
let displayClass = null; let displayClass = null;
try { try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
try { try {
let promise = window.minimizeAll(displayClass.id); let promise = window.minimizeAll(displayClass.id);
promise.then(()=> { promise.then(()=> {
console.info('Succeeded in minimizing all windows.'); console.info('Succeeded in minimizing all windows.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
}; }
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
## window.toggleShownStateForAllAppWindows<sup>9+</sup> ## window.toggleShownStateForAllAppWindows<sup>9+</sup>
...@@ -644,7 +642,7 @@ window.toggleShownStateForAllAppWindows((err) => { ...@@ -644,7 +642,7 @@ window.toggleShownStateForAllAppWindows((err) => {
return; return;
} }
console.info('Succeeded in toggling shown state for all app windows.'); console.info('Succeeded in toggling shown state for all app windows.');
}) });
``` ```
## window.toggleShownStateForAllAppWindows<sup>9+</sup> ## window.toggleShownStateForAllAppWindows<sup>9+</sup>
...@@ -678,7 +676,7 @@ promise.then(()=> { ...@@ -678,7 +676,7 @@ promise.then(()=> {
console.info('Succeeded in toggling shown state for all app windows.'); console.info('Succeeded in toggling shown state for all app windows.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err)); console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
}) });
``` ```
## window.setWindowLayoutMode<sup>9+</sup> ## window.setWindowLayoutMode<sup>9+</sup>
...@@ -718,7 +716,7 @@ try { ...@@ -718,7 +716,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.setWindowLayoutMode<sup>9+</sup> ## window.setWindowLayoutMode<sup>9+</sup>
...@@ -762,7 +760,7 @@ try { ...@@ -762,7 +760,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.on('systemBarTintChange')<sup>8+</sup> ## window.on('systemBarTintChange')<sup>8+</sup>
...@@ -778,9 +776,9 @@ Enables listening for properties changes of the status bar and navigation bar. ...@@ -778,9 +776,9 @@ Enables listening for properties changes of the status bar and navigation bar.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.| | type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.|
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | Yes | Callback used to return the properties of the status bar and navigation bar. | | callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | Yes | Callback used to return the properties of the status bar and navigation bar. |
**Example** **Example**
...@@ -791,7 +789,7 @@ try { ...@@ -791,7 +789,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.off('systemBarTintChange')<sup>8+</sup> ## window.off('systemBarTintChange')<sup>8+</sup>
...@@ -807,9 +805,9 @@ Disables listening for properties changes of the status bar and navigation bar. ...@@ -807,9 +805,9 @@ Disables listening for properties changes of the status bar and navigation bar.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.| | type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.|
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | No | Callback used to return the properties of the status bar and navigation bar. | | callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | No | Callback used to return the properties of the status bar and navigation bar. |
**Example** **Example**
...@@ -818,7 +816,7 @@ try { ...@@ -818,7 +816,7 @@ try {
window.off('systemBarTintChange'); window.off('systemBarTintChange');
} catch (exception) { } catch (exception) {
console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.create<sup>(deprecated)</sup> ## window.create<sup>(deprecated)</sup>
...@@ -901,9 +899,7 @@ promise.then((data)=> { ...@@ -901,9 +899,7 @@ promise.then((data)=> {
create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
Creates a subwindow in the FA model Creates a subwindow in the FA model or a system window in the stage model. This API uses an asynchronous callback to return the result.
or a system window in the stage model. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
...@@ -939,9 +935,7 @@ window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, ...@@ -939,9 +935,7 @@ window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT,
create(ctx: BaseContext, id: string, type: WindowType): Promise&lt;Window&gt; create(ctx: BaseContext, id: string, type: WindowType): Promise&lt;Window&gt;
Creates a subwindow in the FA model Creates a subwindow in the FA model or a system window in the stage model. This API uses a promise to return the result.
or a system window in the stage model. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
...@@ -1110,7 +1104,7 @@ promise.then((data)=> { ...@@ -1110,7 +1104,7 @@ promise.then((data)=> {
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}) });
``` ```
## window.getTopWindow<sup>(deprecated)</sup> ## window.getTopWindow<sup>(deprecated)</sup>
...@@ -1180,7 +1174,7 @@ promise.then((data)=> { ...@@ -1180,7 +1174,7 @@ promise.then((data)=> {
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}) });
``` ```
## Window ## Window
...@@ -1221,8 +1215,8 @@ windowClass.hide((err) => { ...@@ -1221,8 +1215,8 @@ windowClass.hide((err) => {
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data)); console.info('Succeeded in hiding the window.');
}) });
``` ```
### hide<sup>7+</sup> ### hide<sup>7+</sup>
...@@ -1257,7 +1251,7 @@ promise.then(()=> { ...@@ -1257,7 +1251,7 @@ promise.then(()=> {
console.info('Succeeded in hiding the window.'); console.info('Succeeded in hiding the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### hideWithAnimation<sup>9+</sup> ### hideWithAnimation<sup>9+</sup>
...@@ -1295,7 +1289,7 @@ windowClass.hideWithAnimation((err) => { ...@@ -1295,7 +1289,7 @@ windowClass.hideWithAnimation((err) => {
return; return;
} }
console.info('Succeeded in hiding the window with animation.'); console.info('Succeeded in hiding the window with animation.');
}) });
``` ```
### hideWithAnimation<sup>9+</sup> ### hideWithAnimation<sup>9+</sup>
...@@ -1329,10 +1323,10 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -1329,10 +1323,10 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```js ```js
let promise = windowClass.hideWithAnimation(); let promise = windowClass.hideWithAnimation();
promise.then(()=> { promise.then(()=> {
console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); console.info('Succeeded in hiding the window with animation.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
}) });
``` ```
### showWindow<sup>9+</sup> ### showWindow<sup>9+</sup>
...@@ -1437,7 +1431,7 @@ windowClass.showWithAnimation((err) => { ...@@ -1437,7 +1431,7 @@ windowClass.showWithAnimation((err) => {
return; return;
} }
console.info('Succeeded in showing the window with animation.'); console.info('Succeeded in showing the window with animation.');
}) });
``` ```
### showWithAnimation<sup>9+</sup> ### showWithAnimation<sup>9+</sup>
...@@ -1474,7 +1468,7 @@ promise.then(()=> { ...@@ -1474,7 +1468,7 @@ promise.then(()=> {
console.info('Succeeded in showing the window with animation.'); console.info('Succeeded in showing the window with animation.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
}) });
``` ```
### destroyWindow<sup>9+</sup> ### destroyWindow<sup>9+</sup>
...@@ -1509,7 +1503,7 @@ windowClass.destroyWindow((err) => { ...@@ -1509,7 +1503,7 @@ windowClass.destroyWindow((err) => {
return; return;
} }
console.info('Succeeded in destroying the window.'); console.info('Succeeded in destroying the window.');
}) });
``` ```
### destroyWindow<sup>9+</sup> ### destroyWindow<sup>9+</sup>
...@@ -1543,7 +1537,7 @@ promise.then(()=> { ...@@ -1543,7 +1537,7 @@ promise.then(()=> {
console.info('Succeeded in destroying the window.'); console.info('Succeeded in destroying the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### moveWindowTo<sup>9+</sup> ### moveWindowTo<sup>9+</sup>
...@@ -1584,7 +1578,7 @@ try { ...@@ -1584,7 +1578,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
``` ```
### moveWindowTo<sup>9+</sup> ### moveWindowTo<sup>9+</sup>
...@@ -1629,7 +1623,7 @@ try { ...@@ -1629,7 +1623,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
``` ```
### resize<sup>9+</sup> ### resize<sup>9+</sup>
...@@ -1638,6 +1632,12 @@ resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1638,6 +1632,12 @@ resize(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. Changes the size of this window. This API uses an asynchronous callback to return the result.
The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp.
The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp.
The new width and height you set must meet the limits.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
...@@ -1670,7 +1670,7 @@ try { ...@@ -1670,7 +1670,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(exception)); console.error('Failed to change the window size. Cause:' + JSON.stringify(exception));
}; }
``` ```
### resize<sup>9+</sup> ### resize<sup>9+</sup>
...@@ -1679,6 +1679,12 @@ resize(width: number, height: number): Promise&lt;void&gt; ...@@ -1679,6 +1679,12 @@ resize(width: number, height: number): Promise&lt;void&gt;
Changes the size of this window. This API uses a promise to return the result. Changes the size of this window. This API uses a promise to return the result.
The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp.
The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp.
The new width and height you set must meet the limits.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
...@@ -1715,7 +1721,7 @@ try { ...@@ -1715,7 +1721,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception)); console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowMode<sup>9+</sup> ### setWindowMode<sup>9+</sup>
...@@ -1758,7 +1764,7 @@ try { ...@@ -1758,7 +1764,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowMode<sup>9+</sup> ### setWindowMode<sup>9+</sup>
...@@ -1797,7 +1803,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -1797,7 +1803,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```js ```js
let mode = window.WindowMode.FULLSCREEN; let mode = window.WindowMode.FULLSCREEN;
try { try {
let promise = windowClass.setWindowMode(type); let promise = windowClass.setWindowMode(mode);
promise.then(()=> { promise.then(()=> {
console.info('Succeeded in setting the window mode.'); console.info('Succeeded in setting the window mode.');
}).catch((err)=>{ }).catch((err)=>{
...@@ -1805,7 +1811,7 @@ try { ...@@ -1805,7 +1811,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### getWindowProperties<sup>9+</sup> ### getWindowProperties<sup>9+</sup>
...@@ -1837,7 +1843,7 @@ try { ...@@ -1837,7 +1843,7 @@ try {
let properties = windowClass.getWindowProperties(); let properties = windowClass.getWindowProperties();
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### getWindowAvoidArea<sup>9+</sup> ### getWindowAvoidArea<sup>9+</sup>
...@@ -1876,7 +1882,7 @@ try { ...@@ -1876,7 +1882,7 @@ try {
let avoidArea = windowClass.getWindowAvoidArea(type); let avoidArea = windowClass.getWindowAvoidArea(type);
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception)); console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowLayoutFullScreen<sup>9+</sup> ### setWindowLayoutFullScreen<sup>9+</sup>
...@@ -1917,7 +1923,7 @@ try { ...@@ -1917,7 +1923,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowLayoutFullScreen<sup>9+</sup> ### setWindowLayoutFullScreen<sup>9+</sup>
...@@ -1962,7 +1968,7 @@ try { ...@@ -1962,7 +1968,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowSystemBarEnable<sup>9+</sup> ### setWindowSystemBarEnable<sup>9+</sup>
...@@ -1976,8 +1982,8 @@ Sets whether to display the status bar and navigation bar in this window. This A ...@@ -1976,8 +1982,8 @@ Sets whether to display the status bar and navigation bar in this window. This A
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | ------------------------- | -- | --------- | | -------- | ---------------------------- | -- | --------- |
| names | Array | Yes| Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed.| | names | Array<'status'\|'navigation'> | Yes | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes** **Error codes**
...@@ -2004,7 +2010,7 @@ try { ...@@ -2004,7 +2010,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowSystemBarEnable<sup>9+</sup> ### setWindowSystemBarEnable<sup>9+</sup>
...@@ -2018,8 +2024,8 @@ Sets whether to display the status bar and navigation bar in this window. This A ...@@ -2018,8 +2024,8 @@ Sets whether to display the status bar and navigation bar in this window. This A
**Parameters** **Parameters**
| Name| Type | Mandatory| Description| | Name| Type | Mandatory| Description|
| ----- | ----- | -- | ------------------------------------------------------------------------------------------------------------ | | ----- | ---------------------------- | -- | --------------------------------- |
| names | Array | Yes| Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed.| | names | Array<'status'\|'navigation'> | Yes| Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed.|
**Return value** **Return value**
...@@ -2050,7 +2056,7 @@ try { ...@@ -2050,7 +2056,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowSystemBarProperties<sup>9+</sup> ### setWindowSystemBarProperties<sup>9+</sup>
...@@ -2080,7 +2086,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -2080,7 +2086,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```js
let SystemBarProperties={ let SystemBarProperties = {
statusBarColor: '#ff00ff', statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00', navigationBarColor: '#00ff00',
// The following properties are supported since API version 8. // The following properties are supported since API version 8.
...@@ -2097,7 +2103,7 @@ try { ...@@ -2097,7 +2103,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowSystemBarProperties<sup>9+</sup> ### setWindowSystemBarProperties<sup>9+</sup>
...@@ -2132,7 +2138,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -2132,7 +2138,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```js
let SystemBarProperties={ let SystemBarProperties = {
statusBarColor: '#ff00ff', statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00', navigationBarColor: '#00ff00',
// The following properties are supported since API version 8. // The following properties are supported since API version 8.
...@@ -2148,7 +2154,7 @@ try { ...@@ -2148,7 +2154,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setPreferredOrientation<sup>9+</sup> ### setPreferredOrientation<sup>9+</sup>
...@@ -2188,7 +2194,7 @@ try { ...@@ -2188,7 +2194,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setPreferredOrientation<sup>9+</sup> ### setPreferredOrientation<sup>9+</sup>
...@@ -2232,7 +2238,7 @@ try { ...@@ -2232,7 +2238,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setUIContent<sup>9+</sup> ### setUIContent<sup>9+</sup>
...@@ -2272,7 +2278,7 @@ try { ...@@ -2272,7 +2278,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setUIContent<sup>9+</sup> ### setUIContent<sup>9+</sup>
...@@ -2316,7 +2322,7 @@ try { ...@@ -2316,7 +2322,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause: ' + JSON.stringify(exception)); console.error('Failed to load the content. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -2334,7 +2340,7 @@ Loads content from a page associated with a local storage to this window. This A ...@@ -2334,7 +2340,7 @@ Loads content from a page associated with a local storage to this window. This A
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | Path of the page from which the content will be loaded. | | path | string | Yes | Path of the page from which the content will be loaded. |
| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| | storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2362,7 +2368,7 @@ try { ...@@ -2362,7 +2368,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; }
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -2380,7 +2386,7 @@ Loads content from a page associated with a local storage to this window. This A ...@@ -2380,7 +2386,7 @@ Loads content from a page associated with a local storage to this window. This A
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | Path of the page from which the content will be loaded. | | path | string | Yes | Path of the page from which the content will be loaded. |
| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| | storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
**Return value** **Return value**
...@@ -2412,7 +2418,7 @@ try { ...@@ -2412,7 +2418,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; }
``` ```
### isWindowShowing<sup>9+</sup> ### isWindowShowing<sup>9+</sup>
...@@ -2445,7 +2451,7 @@ try { ...@@ -2445,7 +2451,7 @@ try {
console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
} catch (exception) { } catch (exception) {
console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception)); console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('windowSizeChange')<sup>7+</sup> ### on('windowSizeChange')<sup>7+</sup>
...@@ -2472,7 +2478,7 @@ try { ...@@ -2472,7 +2478,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('windowSizeChange')<sup>7+</sup> ### off('windowSizeChange')<sup>7+</sup>
...@@ -2497,7 +2503,7 @@ try { ...@@ -2497,7 +2503,7 @@ try {
windowClass.off('windowSizeChange'); windowClass.off('windowSizeChange');
} catch (exception) { } catch (exception) {
console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('avoidAreaChange')<sup>9+</sup> ### on('avoidAreaChange')<sup>9+</sup>
...@@ -2525,7 +2531,7 @@ try { ...@@ -2525,7 +2531,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('avoidAreaChange')<sup>9+</sup> ### off('avoidAreaChange')<sup>9+</sup>
...@@ -2550,7 +2556,7 @@ try { ...@@ -2550,7 +2556,7 @@ try {
windowClass.off('avoidAreaChange'); windowClass.off('avoidAreaChange');
} catch (exception) { } catch (exception) {
console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('keyboardHeightChange')<sup>7+</sup> ### on('keyboardHeightChange')<sup>7+</sup>
...@@ -2577,7 +2583,7 @@ try { ...@@ -2577,7 +2583,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('keyboardHeightChange')<sup>7+</sup> ### off('keyboardHeightChange')<sup>7+</sup>
...@@ -2602,7 +2608,7 @@ try { ...@@ -2602,7 +2608,7 @@ try {
windowClass.off('keyboardHeightChange'); windowClass.off('keyboardHeightChange');
} catch (exception) { } catch (exception) {
console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('touchOutside')<sup>9+</sup> ### on('touchOutside')<sup>9+</sup>
...@@ -2631,7 +2637,7 @@ try { ...@@ -2631,7 +2637,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('touchOutside')<sup>9+</sup> ### off('touchOutside')<sup>9+</sup>
...@@ -2658,7 +2664,7 @@ try { ...@@ -2658,7 +2664,7 @@ try {
windowClass.off('touchOutside'); windowClass.off('touchOutside');
} catch (exception) { } catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('screenshot')<sup>9+</sup> ### on('screenshot')<sup>9+</sup>
...@@ -2685,7 +2691,7 @@ try { ...@@ -2685,7 +2691,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('screenshot')<sup>9+</sup> ### off('screenshot')<sup>9+</sup>
...@@ -2706,21 +2712,21 @@ Unsubscribes from screenshot events. ...@@ -2706,21 +2712,21 @@ Unsubscribes from screenshot events.
**Example** **Example**
```js ```js
let callback = ()=>{ let callback = () => {
console.info('screenshot happened'); console.info('screenshot happened');
}; };
try { try {
windowClass.on('screenshot', callback); windowClass.on('screenshot', callback);
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
}; }
try { try {
windowClass.off('screenshot', callback); windowClass.off('screenshot', callback);
// If multiple callbacks are enabled in on(), they will all be disabled. // If multiple callbacks are enabled in on(), they will all be disabled.
windowClass.off('screenshot'); windowClass.off('screenshot');
} catch (exception) { } catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('dialogTargetTouch')<sup>9+</sup> ### on('dialogTargetTouch')<sup>9+</sup>
...@@ -2747,7 +2753,7 @@ try { ...@@ -2747,7 +2753,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('dialogTargetTouch')<sup>9+</sup> ### off('dialogTargetTouch')<sup>9+</sup>
...@@ -2772,7 +2778,7 @@ try { ...@@ -2772,7 +2778,7 @@ try {
windowClass.off('dialogTargetTouch'); windowClass.off('dialogTargetTouch');
} catch (exception) { } catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### bindDialogTarget<sup>9+</sup> ### bindDialogTarget<sup>9+</sup>
...@@ -2805,6 +2811,8 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -2805,6 +2811,8 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```js
import rpc from '@ohos.rpc';
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log('server died'); console.log('server died');
...@@ -2824,6 +2832,7 @@ class TestRemoteObject extends rpc.RemoteObject { ...@@ -2824,6 +2832,7 @@ class TestRemoteObject extends rpc.RemoteObject {
return false; return false;
} }
} }
let token = new TestRemoteObject('testObject'); let token = new TestRemoteObject('testObject');
try { try {
windowClass.bindDialogTarget(token, () => { windowClass.bindDialogTarget(token, () => {
...@@ -2837,7 +2846,7 @@ try { ...@@ -2837,7 +2846,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
}; }
``` ```
### bindDialogTarget<sup>9+</sup> ### bindDialogTarget<sup>9+</sup>
...@@ -2875,6 +2884,8 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -2875,6 +2884,8 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```js
import rpc from '@ohos.rpc';
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log('server died'); console.log('server died');
...@@ -2894,6 +2905,7 @@ class TestRemoteObject extends rpc.RemoteObject { ...@@ -2894,6 +2905,7 @@ class TestRemoteObject extends rpc.RemoteObject {
return false; return false;
} }
} }
let token = new TestRemoteObject('testObject'); let token = new TestRemoteObject('testObject');
try { try {
let promise = windowClass.bindDialogTarget(token, () => { let promise = windowClass.bindDialogTarget(token, () => {
...@@ -2906,7 +2918,7 @@ try { ...@@ -2906,7 +2918,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
}; }
``` ```
### isWindowSupportWideGamut<sup>9+</sup> ### isWindowSupportWideGamut<sup>9+</sup>
...@@ -3012,7 +3024,7 @@ try { ...@@ -3012,7 +3024,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowColorSpace<sup>9+</sup> ### setWindowColorSpace<sup>9+</sup>
...@@ -3055,7 +3067,7 @@ try { ...@@ -3055,7 +3067,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
}; }
``` ```
### getWindowColorSpace<sup>9+</sup> ### getWindowColorSpace<sup>9+</sup>
...@@ -3116,7 +3128,7 @@ try { ...@@ -3116,7 +3128,7 @@ try {
windowClass.setWindowBackgroundColor(color); windowClass.setWindowBackgroundColor(color);
} catch (exception) { } catch (exception) {
console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowBrightness<sup>9+</sup> ### setWindowBrightness<sup>9+</sup>
...@@ -3157,7 +3169,7 @@ try { ...@@ -3157,7 +3169,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowBrightness<sup>9+</sup> ### setWindowBrightness<sup>9+</sup>
...@@ -3202,7 +3214,7 @@ try { ...@@ -3202,7 +3214,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowFocusable<sup>9+</sup> ### setWindowFocusable<sup>9+</sup>
...@@ -3232,7 +3244,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -3232,7 +3244,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```js
let isFocusable= true; let isFocusable = true;
try { try {
windowClass.setWindowFocusable(isFocusable, (err) => { windowClass.setWindowFocusable(isFocusable, (err) => {
if (err.code) { if (err.code) {
...@@ -3243,7 +3255,7 @@ try { ...@@ -3243,7 +3255,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowFocusable<sup>9+</sup> ### setWindowFocusable<sup>9+</sup>
...@@ -3278,7 +3290,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -3278,7 +3290,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```js
let isFocusable= true; let isFocusable = true;
try { try {
let promise = windowClass.setWindowFocusable(isFocusable); let promise = windowClass.setWindowFocusable(isFocusable);
promise.then(()=> { promise.then(()=> {
...@@ -3288,7 +3300,7 @@ try { ...@@ -3288,7 +3300,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowKeepScreenOn<sup>9+</sup> ### setWindowKeepScreenOn<sup>9+</sup>
...@@ -3329,7 +3341,7 @@ try { ...@@ -3329,7 +3341,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowKeepScreenOn<sup>9+</sup> ### setWindowKeepScreenOn<sup>9+</sup>
...@@ -3374,7 +3386,7 @@ try { ...@@ -3374,7 +3386,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWakeUpScreen()<sup>9+</sup> ### setWakeUpScreen()<sup>9+</sup>
...@@ -3410,7 +3422,7 @@ try { ...@@ -3410,7 +3422,7 @@ try {
windowClass.setWakeUpScreen(wakeUp); windowClass.setWakeUpScreen(wakeUp);
} catch (exception) { } catch (exception) {
console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception)); console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowPrivacyMode<sup>9+</sup> ### setWindowPrivacyMode<sup>9+</sup>
...@@ -3452,7 +3464,7 @@ try { ...@@ -3452,7 +3464,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowPrivacyMode<sup>9+</sup> ### setWindowPrivacyMode<sup>9+</sup>
...@@ -3498,7 +3510,7 @@ try { ...@@ -3498,7 +3510,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setSnapshotSkip<sup>9+</sup> ### setSnapshotSkip<sup>9+</sup>
...@@ -3571,7 +3583,7 @@ try { ...@@ -3571,7 +3583,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowTouchable<sup>9+</sup> ### setWindowTouchable<sup>9+</sup>
...@@ -3616,7 +3628,7 @@ try { ...@@ -3616,7 +3628,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setForbidSplitMove<sup>9+</sup> ### setForbidSplitMove<sup>9+</sup>
...@@ -3659,7 +3671,7 @@ try { ...@@ -3659,7 +3671,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setForbidSplitMove<sup>9+</sup> ### setForbidSplitMove<sup>9+</sup>
...@@ -3706,7 +3718,7 @@ try { ...@@ -3706,7 +3718,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### snapshot<sup>9+</sup> ### snapshot<sup>9+</sup>
...@@ -3810,7 +3822,7 @@ try { ...@@ -3810,7 +3822,7 @@ try {
windowClass.opacity(0.5); windowClass.opacity(0.5);
} catch (exception) { } catch (exception) {
console.error('Failed to opacity. Cause: ' + JSON.stringify(exception)); console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### scale<sup>9+</sup> ### scale<sup>9+</sup>
...@@ -3851,7 +3863,7 @@ try { ...@@ -3851,7 +3863,7 @@ try {
windowClass.scale(obj); windowClass.scale(obj);
} catch (exception) { } catch (exception) {
console.error('Failed to scale. Cause: ' + JSON.stringify(exception)); console.error('Failed to scale. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### rotate<sup>9+</sup> ### rotate<sup>9+</sup>
...@@ -3893,7 +3905,7 @@ try { ...@@ -3893,7 +3905,7 @@ try {
windowClass.rotate(obj); windowClass.rotate(obj);
} catch (exception) { } catch (exception) {
console.error('Failed to rotate. Cause: ' + JSON.stringify(exception)); console.error('Failed to rotate. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### translate<sup>9+</sup> ### translate<sup>9+</sup>
...@@ -3933,7 +3945,7 @@ try { ...@@ -3933,7 +3945,7 @@ try {
windowClass.translate(obj); windowClass.translate(obj);
} catch (exception) { } catch (exception) {
console.error('Failed to translate. Cause: ' + JSON.stringify(exception)); console.error('Failed to translate. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### getTransitionController<sup>9+</sup> ### getTransitionController<sup>9+</sup>
...@@ -3986,16 +3998,16 @@ controller.animationForHidden = (context : window.TransitionContext) => { ...@@ -3986,16 +3998,16 @@ controller.animationForHidden = (context : window.TransitionContext) => {
toWindow.translate(obj); // Set the transition animation. toWindow.translate(obj); // Set the transition animation.
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
) );
console.info('complete transition end'); console.info('complete transition end');
} };
windowClass.hideWithAnimation((err, data) => { windowClass.hideWithAnimation((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
}) });
``` ```
### setBlur<sup>9+</sup> ### setBlur<sup>9+</sup>
...@@ -4030,7 +4042,7 @@ try { ...@@ -4030,7 +4042,7 @@ try {
windowClass.setBlur(4.0); windowClass.setBlur(4.0);
} catch (exception) { } catch (exception) {
console.error('Failed to set blur. Cause: ' + JSON.stringify(exception)); console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setBackdropBlur<sup>9+</sup> ### setBackdropBlur<sup>9+</sup>
...@@ -4065,7 +4077,8 @@ try { ...@@ -4065,7 +4077,8 @@ try {
windowClass.setBackdropBlur(4.0); windowClass.setBackdropBlur(4.0);
} catch (exception) { } catch (exception) {
console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception)); console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setBackdropBlurStyle<sup>9+</sup> ### setBackdropBlurStyle<sup>9+</sup>
...@@ -4100,7 +4113,8 @@ try { ...@@ -4100,7 +4113,8 @@ try {
windowClass.setBackdropBlurStyle(window.BlurStyle.THIN); windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
} catch (exception) { } catch (exception) {
console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception)); console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setShadow<sup>9+</sup> ### setShadow<sup>9+</sup>
...@@ -4138,7 +4152,8 @@ try { ...@@ -4138,7 +4152,8 @@ try {
windowClass.setShadow(4.0, '#FF00FF00', 2, 3); windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
} catch (exception) { } catch (exception) {
console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception)); console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setCornerRadius<sup>9+</sup> ### setCornerRadius<sup>9+</sup>
...@@ -4173,7 +4188,8 @@ try { ...@@ -4173,7 +4188,8 @@ try {
windowClass.setCornerRadius(4.0); windowClass.setCornerRadius(4.0);
} catch (exception) { } catch (exception) {
console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception)); console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### show<sup>(deprecated)</sup> ### show<sup>(deprecated)</sup>
...@@ -4203,7 +4219,8 @@ windowClass.show((err) => { ...@@ -4203,7 +4219,8 @@ windowClass.show((err) => {
return; return;
} }
console.info('Succeeded in showing the window.'); console.info('Succeeded in showing the window.');
}) });
``` ```
### show<sup>(deprecated)</sup> ### show<sup>(deprecated)</sup>
...@@ -4232,7 +4249,8 @@ promise.then(()=> { ...@@ -4232,7 +4249,8 @@ promise.then(()=> {
console.info('Succeeded in showing the window.'); console.info('Succeeded in showing the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### destroy<sup>(deprecated)</sup> ### destroy<sup>(deprecated)</sup>
...@@ -4262,7 +4280,8 @@ windowClass.destroy((err) => { ...@@ -4262,7 +4280,8 @@ windowClass.destroy((err) => {
return; return;
} }
console.info('Succeeded in destroying the window.'); console.info('Succeeded in destroying the window.');
}) });
``` ```
### destroy<sup>(deprecated)</sup> ### destroy<sup>(deprecated)</sup>
...@@ -4291,7 +4310,8 @@ promise.then(()=> { ...@@ -4291,7 +4310,8 @@ promise.then(()=> {
console.info('Succeeded in destroying the window.'); console.info('Succeeded in destroying the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### moveTo<sup>(deprecated)</sup> ### moveTo<sup>(deprecated)</sup>
...@@ -4323,8 +4343,8 @@ windowClass.moveTo(300, 300, (err)=>{ ...@@ -4323,8 +4343,8 @@ windowClass.moveTo(300, 300, (err)=>{
return; return;
} }
console.info('Succeeded in moving the window.'); console.info('Succeeded in moving the window.');
}); });
``` ```
### moveTo<sup>(deprecated)</sup> ### moveTo<sup>(deprecated)</sup>
...@@ -4360,7 +4380,8 @@ promise.then(()=> { ...@@ -4360,7 +4380,8 @@ promise.then(()=> {
console.info('Succeeded in moving the window.'); console.info('Succeeded in moving the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### resetSize<sup>(deprecated)</sup> ### resetSize<sup>(deprecated)</sup>
...@@ -4369,6 +4390,12 @@ resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): v ...@@ -4369,6 +4390,12 @@ resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): v
Changes the size of this window. This API uses an asynchronous callback to return the result. Changes the size of this window. This API uses an asynchronous callback to return the result.
The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp.
The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp.
The new width and height you set must meet the limits.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [resize()](#resize9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [resize()](#resize9) instead.
...@@ -4393,6 +4420,7 @@ windowClass.resetSize(500, 1000, (err) => { ...@@ -4393,6 +4420,7 @@ windowClass.resetSize(500, 1000, (err) => {
} }
console.info('Succeeded in changing the window size.'); console.info('Succeeded in changing the window size.');
}); });
``` ```
### resetSize<sup>(deprecated)</sup> ### resetSize<sup>(deprecated)</sup>
...@@ -4401,6 +4429,12 @@ resetSize(width: number, height: number): Promise&lt;void&gt; ...@@ -4401,6 +4429,12 @@ resetSize(width: number, height: number): Promise&lt;void&gt;
Changes the size of this window. This API uses a promise to return the result. Changes the size of this window. This API uses a promise to return the result.
The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp.
The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp.
The new width and height you set must meet the limits.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [resize()](#resize9-1) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [resize()](#resize9-1) instead.
...@@ -4464,6 +4498,7 @@ windowClass.setWindowType(type, (err) => { ...@@ -4464,6 +4498,7 @@ windowClass.setWindowType(type, (err) => {
} }
console.info('Succeeded in setting the window type.'); console.info('Succeeded in setting the window type.');
}); });
``` ```
### setWindowType<sup>(deprecated)</sup> ### setWindowType<sup>(deprecated)</sup>
...@@ -4502,6 +4537,7 @@ promise.then(()=> { ...@@ -4502,6 +4537,7 @@ promise.then(()=> {
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
}); });
``` ```
### getProperties<sup>(deprecated)</sup> ### getProperties<sup>(deprecated)</sup>
...@@ -4573,7 +4609,7 @@ Obtains the area where this window cannot be displayed, for example, the system ...@@ -4573,7 +4609,7 @@ Obtains the area where this window cannot be displayed, for example, the system
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [[getWindowAvoidArea()](#getwindowavoidarea9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getWindowAvoidArea()](#getwindowavoidarea9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -4595,6 +4631,7 @@ windowClass.getAvoidArea(type, (err, data) => { ...@@ -4595,6 +4631,7 @@ windowClass.getAvoidArea(type, (err, data) => {
} }
console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
}); });
``` ```
### getAvoidArea<sup>(deprecated)</sup> ### getAvoidArea<sup>(deprecated)</sup>
...@@ -4605,7 +4642,7 @@ Obtains the area where this window cannot be displayed, for example, the system ...@@ -4605,7 +4642,7 @@ Obtains the area where this window cannot be displayed, for example, the system
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getWindowProperties()](#getwindowavoidarea9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getWindowAvoidArea()](#getwindowavoidarea9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -4631,6 +4668,7 @@ promise.then((data)=> { ...@@ -4631,6 +4668,7 @@ promise.then((data)=> {
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
}); });
``` ```
### setFullScreen<sup>(deprecated)</sup> ### setFullScreen<sup>(deprecated)</sup>
...@@ -4663,6 +4701,7 @@ windowClass.setFullScreen(isFullScreen, (err) => { ...@@ -4663,6 +4701,7 @@ windowClass.setFullScreen(isFullScreen, (err) => {
} }
console.info('Succeeded in enabling the full-screen mode.'); console.info('Succeeded in enabling the full-screen mode.');
}); });
``` ```
### setFullScreen<sup>(deprecated)</sup> ### setFullScreen<sup>(deprecated)</sup>
...@@ -4769,6 +4808,7 @@ promise.then(()=> { ...@@ -4769,6 +4808,7 @@ promise.then(()=> {
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
}); });
``` ```
### setSystemBarEnable<sup>(deprecated)</sup> ### setSystemBarEnable<sup>(deprecated)</sup>
...@@ -4786,8 +4826,8 @@ Sets whether to display the status bar and navigation bar in this window. This A ...@@ -4786,8 +4826,8 @@ Sets whether to display the status bar and navigation bar in this window. This A
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | --------- | ------------------------------------------------------------ | | -------- | ----------------------------- | --------- | ------------------------------------------------------------ |
| names | Array | Yes | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed. | | names | Array<'status'\|'navigation'> | Yes | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -4820,8 +4860,8 @@ Sets whether to display the status bar and navigation bar in this window. This A ...@@ -4820,8 +4860,8 @@ Sets whether to display the status bar and navigation bar in this window. This A
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ----- | --------- | ------------------------------------------------------------ | | ----- | ----------------------------- | --------- | ------------------------------------------------------------ |
| names | Array | Yes | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed. | | names | Array<'status'\|'navigation'> | Yes | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed. |
**Return value** **Return value**
...@@ -4879,6 +4919,7 @@ windowClass.setSystemBarProperties(SystemBarProperties, (err) => { ...@@ -4879,6 +4919,7 @@ windowClass.setSystemBarProperties(SystemBarProperties, (err) => {
} }
console.info('Succeeded in setting the system bar properties.'); console.info('Succeeded in setting the system bar properties.');
}); });
``` ```
### setSystemBarProperties<sup>(deprecated)</sup> ### setSystemBarProperties<sup>(deprecated)</sup>
...@@ -5020,6 +5061,7 @@ windowClass.isShowing((err, data) => { ...@@ -5020,6 +5061,7 @@ windowClass.isShowing((err, data) => {
} }
console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
}); });
``` ```
### isShowing<sup>(deprecated)</sup> ### isShowing<sup>(deprecated)</sup>
...@@ -5049,6 +5091,7 @@ promise.then((data)=> { ...@@ -5049,6 +5091,7 @@ promise.then((data)=> {
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
}); });
``` ```
### on('systemAvoidAreaChange')<sup>(deprecated)</sup> ### on('systemAvoidAreaChange')<sup>(deprecated)</sup>
...@@ -5076,6 +5119,7 @@ Enables listening for changes to the area where the window cannot be displayed. ...@@ -5076,6 +5119,7 @@ Enables listening for changes to the area where the window cannot be displayed.
windowClass.on('systemAvoidAreaChange', (data) => { windowClass.on('systemAvoidAreaChange', (data) => {
console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
}); });
``` ```
### off('systemAvoidAreaChange')<sup>(deprecated)</sup> ### off('systemAvoidAreaChange')<sup>(deprecated)</sup>
...@@ -5131,7 +5175,7 @@ windowClass.isSupportWideGamut((err, data) => { ...@@ -5131,7 +5175,7 @@ windowClass.isSupportWideGamut((err, data) => {
return; return;
} }
console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
}) });
``` ```
...@@ -5193,7 +5237,8 @@ windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => { ...@@ -5193,7 +5237,8 @@ windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => {
return; return;
} }
console.info('Succeeded in setting window colorspace.'); console.info('Succeeded in setting window colorspace.');
}) });
``` ```
### setColorSpace<sup>(deprecated)</sup> ### setColorSpace<sup>(deprecated)</sup>
...@@ -5259,7 +5304,7 @@ windowClass.getColorSpace((err, data) => { ...@@ -5259,7 +5304,7 @@ windowClass.getColorSpace((err, data) => {
return; return;
} }
console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)); console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
}) });
``` ```
...@@ -5323,6 +5368,7 @@ windowClass.setBackgroundColor(color, (err) => { ...@@ -5323,6 +5368,7 @@ windowClass.setBackgroundColor(color, (err) => {
} }
console.info('Succeeded in setting the background color.'); console.info('Succeeded in setting the background color.');
}); });
``` ```
### setBackgroundColor<sup>(deprecated)</sup> ### setBackgroundColor<sup>(deprecated)</sup>
...@@ -5461,6 +5507,7 @@ windowClass.setDimBehind(0.5, (err) => { ...@@ -5461,6 +5507,7 @@ windowClass.setDimBehind(0.5, (err) => {
} }
console.info('Succeeded in setting the dimness.'); console.info('Succeeded in setting the dimness.');
}); });
``` ```
### setDimBehind<sup>(deprecated)</sup> ### setDimBehind<sup>(deprecated)</sup>
...@@ -5566,6 +5613,7 @@ promise.then(()=> { ...@@ -5566,6 +5613,7 @@ promise.then(()=> {
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setKeepScreenOn<sup>(deprecated)</sup> ### setKeepScreenOn<sup>(deprecated)</sup>
...@@ -5598,6 +5646,7 @@ windowClass.setKeepScreenOn(isKeepScreenOn, (err) => { ...@@ -5598,6 +5646,7 @@ windowClass.setKeepScreenOn(isKeepScreenOn, (err) => {
} }
console.info('Succeeded in setting the screen to be always on.'); console.info('Succeeded in setting the screen to be always on.');
}); });
``` ```
### setKeepScreenOn<sup>(deprecated)</sup> ### setKeepScreenOn<sup>(deprecated)</sup>
...@@ -5634,6 +5683,7 @@ promise.then(() => { ...@@ -5634,6 +5683,7 @@ promise.then(() => {
}).catch((err)=>{ }).catch((err)=>{
console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setOutsideTouchable<sup>(deprecated)</sup> ### setOutsideTouchable<sup>(deprecated)</sup>
...@@ -5664,7 +5714,8 @@ windowClass.setOutsideTouchable(true, (err) => { ...@@ -5664,7 +5714,8 @@ windowClass.setOutsideTouchable(true, (err) => {
return; return;
} }
console.info('Succeeded in setting the area to be touchable.'); console.info('Succeeded in setting the area to be touchable.');
}) });
``` ```
### setOutsideTouchable<sup>(deprecated)</sup> ### setOutsideTouchable<sup>(deprecated)</sup>
...@@ -5700,6 +5751,7 @@ promise.then(()=> { ...@@ -5700,6 +5751,7 @@ promise.then(()=> {
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setPrivacyMode<sup>(deprecated)</sup> ### setPrivacyMode<sup>(deprecated)</sup>
...@@ -5731,7 +5783,6 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => { ...@@ -5731,7 +5783,6 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => {
return; return;
} }
console.info('Succeeded in setting the window to privacy mode.'); console.info('Succeeded in setting the window to privacy mode.');
}); });
``` ```
...@@ -5770,6 +5821,7 @@ promise.then(()=> { ...@@ -5770,6 +5821,7 @@ promise.then(()=> {
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setTouchable<sup>(deprecated)</sup> ### setTouchable<sup>(deprecated)</sup>
...@@ -5801,8 +5853,8 @@ windowClass.setTouchable(isTouchable, (err) => { ...@@ -5801,8 +5853,8 @@ windowClass.setTouchable(isTouchable, (err) => {
return; return;
} }
console.info('Succeeded in setting the window to be touchable.'); console.info('Succeeded in setting the window to be touchable.');
}); });
``` ```
### setTouchable<sup>(deprecated)</sup> ### setTouchable<sup>(deprecated)</sup>
...@@ -5839,6 +5891,7 @@ promise.then(()=> { ...@@ -5839,6 +5891,7 @@ promise.then(()=> {
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
}); });
``` ```
## WindowStageEventType<sup>9+</sup> ## WindowStageEventType<sup>9+</sup>
...@@ -5849,8 +5902,8 @@ Describes the lifecycle of a window stage. ...@@ -5849,8 +5902,8 @@ Describes the lifecycle of a window stage.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Default Value | Description | | Name | Value | Description |
| ---------- | ------------- | ---------------------------------------------- | | ---------- | ----- | ---------------------------------------------- |
| FOREGROUND | 1 | The window stage is running in the foreground. | | FOREGROUND | 1 | The window stage is running in the foreground. |
| ACTIVE | 2 | The window stage gains focus. | | ACTIVE | 2 | The window stage gains focus. |
| INACTIVE | 3 | The window stage loses focus. | | INACTIVE | 3 | The window stage loses focus. |
...@@ -5891,6 +5944,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -5891,6 +5944,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -5904,7 +5958,8 @@ class myAbility extends Ability { ...@@ -5904,7 +5958,8 @@ class myAbility extends Ability {
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
}); });
} }
} };
``` ```
### getMainWindow<sup>9+</sup> ### getMainWindow<sup>9+</sup>
...@@ -5936,19 +5991,21 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -5936,19 +5991,21 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
let promise = windowStage.getMainWindow(); let promise = windowStage.getMainWindow();
promise.then((data)=> { promise.then((data) => {
windowClass = data; windowClass = data;
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
}); });
} }
} };
``` ```
### getMainWindowSync<sup>9+</sup> ### getMainWindowSync<sup>9+</sup>
...@@ -5980,6 +6037,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -5980,6 +6037,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -5989,7 +6047,8 @@ class myAbility extends Ability { ...@@ -5989,7 +6047,8 @@ class myAbility extends Ability {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### createSubWindow<sup>9+</sup> ### createSubWindow<sup>9+</sup>
...@@ -6006,7 +6065,7 @@ Creates a subwindow for this window stage. This API uses an asynchronous callbac ...@@ -6006,7 +6065,7 @@ Creates a subwindow for this window stage. This API uses an asynchronous callbac
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------------------------- | --------- | -------------------------------------- | | -------- | -------------------------------------- | --------- | -------------------------------------- |
| name | String | Yes | Name of the subwindow. | | name | string | Yes | Name of the subwindow. |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow. | | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow. |
**Error codes** **Error codes**
...@@ -6022,6 +6081,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6022,6 +6081,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6040,7 +6100,8 @@ class myAbility extends Ability { ...@@ -6040,7 +6100,8 @@ class myAbility extends Ability {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### createSubWindow<sup>9+</sup> ### createSubWindow<sup>9+</sup>
...@@ -6057,7 +6118,7 @@ Creates a subwindow for this window stage. This API uses a promise to return the ...@@ -6057,7 +6118,7 @@ Creates a subwindow for this window stage. This API uses a promise to return the
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | --------- | ---------------------- | | ---- | ------ | --------- | ---------------------- |
| name | String | Yes | Name of the subwindow. | | name | string | Yes | Name of the subwindow. |
**Return value** **Return value**
...@@ -6078,23 +6139,25 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6078,23 +6139,25 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
try { try {
let promise = windowStage.createSubWindow('mySubWindow'); let promise = windowStage.createSubWindow('mySubWindow');
promise.then((data)=> { promise.then((data) => {
windowClass = data; windowClass = data;
console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### getSubWindow<sup>9+</sup> ### getSubWindow<sup>9+</sup>
...@@ -6125,6 +6188,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6125,6 +6188,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6138,7 +6202,8 @@ class myAbility extends Ability { ...@@ -6138,7 +6202,8 @@ class myAbility extends Ability {
console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
}); });
} }
} };
``` ```
### getSubWindow<sup>9+</sup> ### getSubWindow<sup>9+</sup>
...@@ -6169,19 +6234,21 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6169,19 +6234,21 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
let promise = windowStage.getSubWindow(); let promise = windowStage.getSubWindow();
promise.then((data)=> { promise.then((data) => {
windowClass = data; windowClass = data;
console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
}) })
} }
} };
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -6199,7 +6266,7 @@ Loads content from a page associated with a local storage to the main window in ...@@ -6199,7 +6266,7 @@ Loads content from a page associated with a local storage to the main window in
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
| path | string | Yes | Path of the page from which the content will be loaded. | | path | string | Yes | Path of the page from which the content will be loaded. |
| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. | | storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -6215,6 +6282,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6215,6 +6282,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
storage : LocalStorage storage : LocalStorage
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
...@@ -6233,7 +6301,8 @@ class myAbility extends Ability { ...@@ -6233,7 +6301,8 @@ class myAbility extends Ability {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -6251,7 +6320,7 @@ Loads content from a page associated with a local storage to the main window in ...@@ -6251,7 +6320,7 @@ Loads content from a page associated with a local storage to the main window in
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
| path | string | Yes | Path of the page from which the content will be loaded. | | path | string | Yes | Path of the page from which the content will be loaded. |
| storage | LocalStorage | No | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. | | storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | No | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. |
**Return value** **Return value**
...@@ -6272,6 +6341,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6272,6 +6341,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
storage : LocalStorage storage : LocalStorage
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
...@@ -6280,16 +6350,17 @@ class myAbility extends Ability { ...@@ -6280,16 +6350,17 @@ class myAbility extends Ability {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
try { try {
let promise = windowStage.loadContent('pages/page2',this.storage); let promise = windowStage.loadContent('pages/page2',this.storage);
promise.then(()=> { promise.then(() => {
console.info('Succeeded in loading the content.'); console.info('Succeeded in loading the content.');
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -6322,6 +6393,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6322,6 +6393,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6337,7 +6409,8 @@ class myAbility extends Ability { ...@@ -6337,7 +6409,8 @@ class myAbility extends Ability {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### on('windowStageEvent')<sup>9+</sup> ### on('windowStageEvent')<sup>9+</sup>
...@@ -6370,6 +6443,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6370,6 +6443,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6383,7 +6457,8 @@ class myAbility extends Ability { ...@@ -6383,7 +6457,8 @@ class myAbility extends Ability {
JSON.stringify(exception)); JSON.stringify(exception));
}; };
} }
} };
``` ```
### off('windowStageEvent')<sup>9+</sup> ### off('windowStageEvent')<sup>9+</sup>
...@@ -6416,6 +6491,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6416,6 +6491,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6426,7 +6502,8 @@ class myAbility extends Ability { ...@@ -6426,7 +6502,8 @@ class myAbility extends Ability {
JSON.stringify(exception)); JSON.stringify(exception));
}; };
} }
} };
``` ```
### disableWindowDecor()<sup>9+</sup> ### disableWindowDecor()<sup>9+</sup>
...@@ -6454,12 +6531,14 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6454,12 +6531,14 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('disableWindowDecor'); console.log('disableWindowDecor');
windowStage.disableWindowDecor(); windowStage.disableWindowDecor();
} }
} };
``` ```
### setShowOnLockScreen()<sup>9+</sup> ### setShowOnLockScreen()<sup>9+</sup>
...@@ -6493,6 +6572,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc ...@@ -6493,6 +6572,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6502,7 +6582,8 @@ class myAbility extends Ability { ...@@ -6502,7 +6582,8 @@ class myAbility extends Ability {
console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception)); console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
}; };
} }
} };
``` ```
## TransitionContext<sup>9+</sup> ## TransitionContext<sup>9+</sup>
...@@ -6557,7 +6638,7 @@ controller.animationForShown = (context : window.TransitionContext) => { ...@@ -6557,7 +6638,7 @@ controller.animationForShown = (context : window.TransitionContext) => {
toWindow.translate(obj); toWindow.translate(obj);
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
) );
try { try {
context.completeTransition(true) context.completeTransition(true)
} catch (exception) { } catch (exception) {
...@@ -6565,6 +6646,7 @@ controller.animationForShown = (context : window.TransitionContext) => { ...@@ -6565,6 +6646,7 @@ controller.animationForShown = (context : window.TransitionContext) => {
} }
console.info('complete transition end'); console.info('complete transition end');
}; };
``` ```
## TransitionController<sup>9+</sup> ## TransitionController<sup>9+</sup>
...@@ -6612,9 +6694,10 @@ controller.animationForShown = (context : window.TransitionContext) => { ...@@ -6612,9 +6694,10 @@ controller.animationForShown = (context : window.TransitionContext) => {
toWindow.translate(obj); toWindow.translate(obj);
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
) );
console.info('complete transition end'); console.info('complete transition end');
} };
``` ```
### animationForHidden<sup>9+</sup> ### animationForHidden<sup>9+</sup>
...@@ -6660,6 +6743,5 @@ controller.animationForHidden = (context : window.TransitionContext) => { ...@@ -6660,6 +6743,5 @@ controller.animationForHidden = (context : window.TransitionContext) => {
} }
) )
console.info('complete transition end'); console.info('complete transition end');
} };
``` ```
\ No newline at end of file
...@@ -57,7 +57,8 @@ In the stage model, the main window of an application is created and maintained ...@@ -57,7 +57,8 @@ In the stage model, the main window of an application is created and maintained
1. Obtain the main window. 1. Obtain the main window.
Call **getMainWindow** to obtain the main window of the application.
Call **getMainWindow** to obtain the main window of the application.
2. Set the properties of the main window. 2. Set the properties of the main window.
...@@ -83,21 +84,21 @@ class MainAbility extends Ability { ...@@ -83,21 +84,21 @@ class MainAbility extends Ability {
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
// 2. Set the touchable property of the main window. // 2. Set the touchable property of the main window.
let isTouchable = true; let isTouchable = true;
windowClass.setTouchable(isTouchable, (err, data) => { windowClass.setTouchable(isTouchable, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); console.info('Succeeded in setting the window to be touchable.');
}) })
}) })
// 3. Load the page content to the main window. // 3. Load the page content to the main window.
windowStage.loadContent("pages/page2", (err, data) => { windowStage.loadContent("pages/page2", (err) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content.');
}); });
} }
}; };
...@@ -111,11 +112,10 @@ You can create an application subwindow, such as a dialog box, and set its prope ...@@ -111,11 +112,10 @@ You can create an application subwindow, such as a dialog box, and set its prope
### How to Develop ### How to Develop
1. Create or obtain a subwindow. 1. Create a subwindow.
Call **createSubWindow** to create a subwindow.
Call **getSubWindow** to obtain a subwindow. Call **createSubWindow** to create a subwindow.
2. Set the properties of the subwindow. 2. Set the properties of the subwindow.
...@@ -144,44 +144,35 @@ Call **getSubWindow** to obtain a subwindow. ...@@ -144,44 +144,35 @@ Call **getSubWindow** to obtain a subwindow.
} }
sub_windowClass = data; sub_windowClass = data;
console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
// 1. Obtain an available subwindow.
windowStage_.getSubWindow((err, data) => {
if (err.code) {
console.error('Failed to obtain the subWindow. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in obtaining the subWindow. Data: ' + JSON.stringify(data));
sub_windowClass = data;
});
// 2. Set the position, size, and other properties of the subwindow. // 2. Set the position, size, and other properties of the subwindow.
sub_windowClass.moveTo(300, 300, (err, data) => { sub_windowClass.moveTo(300, 300, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to move the window. Cause:' + JSON.stringify(err)); console.error('Failed to move the window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in moving the window.');
}); });
sub_windowClass.resetSize(500, 1000, (err, data) => { sub_windowClass.resetSize(500, 1000, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); console.info('Succeeded in changing the window size.');
}); });
// 3. Load the page content to the subwindow. // 3. Load the page content to the subwindow.
sub_windowClass.loadContent("pages/page3", (err, data) => { sub_windowClass.loadContent("pages/page3", (err) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content.');
// 3. Show the subwindow. // 3. Show the subwindow.
sub_windowClass.show((err, data) => { sub_windowClass.show((err) => {
if (err.code) { if (err.code) {
console.error('Failed to show the window. Cause:' + JSON.stringify(err)); console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in showing the window.');
}); });
}); });
}) })
...@@ -189,18 +180,18 @@ Call **getSubWindow** to obtain a subwindow. ...@@ -189,18 +180,18 @@ Call **getSubWindow** to obtain a subwindow.
destroySubWindow() { destroySubWindow() {
// 4. Destroy the subwindow when it is no longer needed (depending on the service logic). // 4. Destroy the subwindow when it is no longer needed (depending on the service logic).
sub_windowClass.destroy((err, data) => { sub_windowClass.destroy((err) => {
if (err.code) { if (err.code) {
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in destroying the window.');
}); });
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
windowStage_ = windowStage; windowStage_ = windowStage;
// Create the subwindow when it is needed, for example, when a click event occurs in the main window. Calling onWindowStageCreate is not always necessary. The code here is for reference only. // Create a subwindow when it is needed, for example, when a click event occurs in the main window. Calling onWindowStageCreate is not always necessary. The code here is for reference only.
this.showSubWindow(); this.showSubWindow();
} }
...@@ -221,7 +212,8 @@ To create a better video watching and gaming experience, you can use the immersi ...@@ -221,7 +212,8 @@ To create a better video watching and gaming experience, you can use the immersi
1. Obtain the main window. 1. Obtain the main window.
Call **getMainWindow** to obtain the main window of the application.
Call **getMainWindow** to obtain the main window of the application.
2. Implement the immersive effect. You can use any of the following methods: 2. Implement the immersive effect. You can use any of the following methods:
- Method 1: Call **setFullScreen** to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden. - Method 1: Call **setFullScreen** to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden.
...@@ -249,30 +241,30 @@ Call **getMainWindow** to obtain the main window of the application. ...@@ -249,30 +241,30 @@ Call **getMainWindow** to obtain the main window of the application.
// 2. Use method 1 to implement the immersive effect. // 2. Use method 1 to implement the immersive effect.
let isFullScreen = true; let isFullScreen = true;
windowClass.setFullScreen(isFullScreen, (err, data) => { windowClass.setFullScreen(isFullScreen, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); console.info('Succeeded in enabling the full-screen mode.');
}); });
// 2. Use method 2 to implement the immersive effect. // 2. Use method 2 to implement the immersive effect.
let names = []; let names = [];
windowClass.setSystemBarEnable(names, (err, data) => { windowClass.setSystemBarEnable(names, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the system bar to be visible.');
}); });
// 2. Use method 3 to implement the immersive effect. // 2. Use method 3 to implement the immersive effect.
let isLayoutFullScreen = true; let isLayoutFullScreen = true;
windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { windowClass.setLayoutFullScreen(isLayoutFullScreen, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the window layout to full-screen mode.');
}); });
let sysBarProps = { let sysBarProps = {
statusBarColor: '#ff00ff', statusBarColor: '#ff00ff',
...@@ -281,21 +273,21 @@ Call **getMainWindow** to obtain the main window of the application. ...@@ -281,21 +273,21 @@ Call **getMainWindow** to obtain the main window of the application.
statusBarContentColor: '#ffffff', statusBarContentColor: '#ffffff',
navigationBarContentColor: '#ffffff' navigationBarContentColor: '#ffffff'
}; };
windowClass.setSystemBarProperties(sysBarProps, (err, data) => { windowClass.setSystemBarProperties(sysBarProps, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the system bar properties.');
}); });
}) })
// 3. Load the page content to the immersive window. // 3. Load the page content to the immersive window.
windowStage.loadContent("pages/page2", (err, data) => { windowStage.loadContent("pages/page2", (err) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content.');
}); });
} }
}; };
...@@ -311,7 +303,7 @@ A floating window is created based on an existing task. It is always displayed i ...@@ -311,7 +303,7 @@ A floating window is created based on an existing task. It is always displayed i
1. Apply for permissions. 1. Apply for permissions.
To create a floating window (of the **WindowType.TYPE_FLOAT** type), you must configure the **ohos.permission.SYSTEM_FLOAT_WINDOW** permission in the **requestPermissions** field of the **module.json5** file. For details about the file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To create a floating window (of the **WindowType.TYPE_FLOAT** type), you must configure the **ohos.permission.SYSTEM_FLOAT_WINDOW** permission in the **requestPermissions** field of the **module.json5** file. For details about the file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md).
> **NOTE** > **NOTE**
> >
...@@ -368,43 +360,43 @@ To create a floating window (of the **WindowType.TYPE_FLOAT** type), you must co ...@@ -368,43 +360,43 @@ To create a floating window (of the **WindowType.TYPE_FLOAT** type), you must co
console.info('Succeeded in creating the floatWindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the floatWindow. Data: ' + JSON.stringify(data));
windowClass = data; windowClass = data;
// 3. Set the position, size, and properties of the floating window. // 3. Set the position, size, and properties of the floating window.
windowClass.moveTo(300, 300, (err, data) => { windowClass.moveTo(300, 300, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to move the window. Cause:' + JSON.stringify(err)); console.error('Failed to move the window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in moving the window.');
}); });
windowClass.resetSize(500, 1000, (err, data) => { windowClass.resetSize(500, 1000, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); console.info('Succeeded in changing the window size.');
}); });
// 4. Load the page content to the floating window. // 4. Load the page content to the floating window.
windowClass.loadContent("pages/page4", (err, data) => { windowClass.loadContent("pages/page4", (err) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content.');
// 4. Show the floating window. // 4. Show the floating window.
windowClass.show((err, data) => { windowClass.show((err) => {
if (err.code) { if (err.code) {
console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in showing the window.');
}); });
}); });
// 5. Destroy the floating window when it is no longer needed (depending on the service logic). // 5. Destroy the floating window when it is no longer needed (depending on the service logic).
windowClass.destroy((err, data) => { windowClass.destroy((err) => {
if (err.code) { if (err.code) {
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in destroying the window.');
}); });
}); });
} }
......
...@@ -65,46 +65,46 @@ export default class ServiceExtensionAbility1 extends ExtensionContext { ...@@ -65,46 +65,46 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
console.info('Succeeded in creating the volume window.') console.info('Succeeded in creating the volume window.')
windowClass = data; windowClass = data;
// 2. Change the size and position of the volume bar window, or set its properties such as the background color and brightness. // 2. Change the size and position of the volume bar window, or set its properties such as the background color and brightness.
windowClass.moveTo(300, 300, (err, data) => { windowClass.moveTo(300, 300, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to move the window. Cause:' + JSON.stringify(err)); console.error('Failed to move the window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in moving the window.');
}); });
windowClass.resetSize(500, 1000, (err, data) => { windowClass.resetSize(500, 1000, (err) => {
if (err.code) { if (err.code) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); console.info('Succeeded in changing the window size.');
}); });
// 3. Load the page content to the volume bar window. // 3. Load the page content to the volume bar window.
windowClass.loadContent("pages/page_volume", (err, data) => { windowClass.loadContent("pages/page_volume", (err) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content.');
// 3. Show the volume bar window. // 3. Show the volume bar window.
windowClass.show((err, data) => { windowClass.show((err) => {
if (err.code) { if (err.code) {
console.error('Failed to show the window. Cause:' + JSON.stringify(err)); console.error('Failed to show the window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in showing the window.');
}); });
}); });
// 4. Hide or destroy the volume bar window. // 4. Hide or destroy the volume bar window.
// Hide the volume bar window when a click event outside the window is detected. // Hide the volume bar window when a click event outside the window is detected.
windowClass.on('touchOutside', () => { windowClass.on('touchOutside', () => {
console.info('touch outside'); console.info('touch outside');
windowClass.hide((err, data) => { windowClass.hide((err) => {
if (err.code) { if (err.code) {
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in hidinging the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in hidinging the window.');
}); });
}); });
}); });
......
...@@ -63,4 +63,8 @@ You are advised to use the stage model for window development. ...@@ -63,4 +63,8 @@ You are advised to use the stage model for window development.
## Constraints ## Constraints
You cannot develop system windows in the FA model. - You cannot develop system windows in the FA model.
- The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp.
- The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册