| 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.
| 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**.|
| 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<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the properties of the status bar and navigation bar. |
| callback | Callback<[SystemBarTintState](#systembartintstate8)> | 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>
...
@@ -806,10 +804,10 @@ Disables listening for properties changes of the status bar and navigation bar.
...
@@ -806,10 +804,10 @@ Disables listening for properties changes 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.|
| 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<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the properties of the status bar and navigation bar. |
| callback | Callback<[SystemBarTintState](#systembartintstate8)> | 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));
| 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<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | 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
| 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
letSystemBarProperties={
letSystemBarProperties={
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
letSystemBarProperties={
letSystemBarProperties={
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
| 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<void> | Yes | Callback used to return the result. |
| callback | AsyncCallback<void> | 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
| 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
letcallback=()=>{
letcallback=()=>{
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
importrpcfrom'@ohos.rpc';
classMyDeathRecipient{
classMyDeathRecipient{
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 {
returnfalse;
returnfalse;
}
}
}
}
lettoken=newTestRemoteObject('testObject');
lettoken=newTestRemoteObject('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
importrpcfrom'@ohos.rpc';
classMyDeathRecipient{
classMyDeathRecipient{
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 {
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.
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.
| 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<void> | Yes | Callback used to return the result. |
| callback | AsyncCallback<void>| Yes | Callback used to return the result. |
**Example**
**Example**
...
@@ -4819,9 +4859,9 @@ Sets whether to display the status bar and navigation bar in this window. This A
...
@@ -4819,9 +4859,9 @@ Sets whether to display the status bar and navigation bar in this window. This A
| 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. |
| 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<void> | Yes | Callback used to return the result. |
| callback | AsyncCallback<void> | 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
importAbilityfrom'@ohos.application.Ability';
importAbilityfrom'@ohos.application.Ability';
classmyAbilityextendsAbility{
classmyAbilityextendsAbility{
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
| 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
importAbilityfrom'@ohos.application.Ability';
importAbilityfrom'@ohos.application.Ability';
classmyAbilityextendsAbility{
classmyAbilityextendsAbility{
storage:LocalStorage
storage:LocalStorage
onWindowStageCreate(windowStage){
onWindowStageCreate(windowStage){
...
@@ -6280,16 +6350,17 @@ class myAbility extends Ability {
...
@@ -6280,16 +6350,17 @@ class myAbility extends Ability {
@@ -57,8 +57,9 @@ In the stage model, the main window of an application is created and maintained
...
@@ -57,8 +57,9 @@ 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.
You can set multiple properties of the main window, such as the background color, brightness, and whether the main window is touchable. The code snippet below uses the **touchable** property as an example.
You can set multiple properties of the main window, such as the background color, brightness, and whether the main window is touchable. The code snippet below uses the **touchable** property as an example.
...
@@ -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.
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,8 +212,9 @@ To create a better video watching and gaming experience, you can use the immersi
...
@@ -221,8 +212,9 @@ 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.
- Method 2: Call **setSystemBarEnable** to hide the navigation bar and status bar.
- Method 2: Call **setSystemBarEnable** to hide the navigation bar and status bar.
...
@@ -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.
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.');
});
});
}
}
};
};
...
@@ -310,13 +302,13 @@ A floating window is created based on an existing task. It is always displayed i
...
@@ -310,13 +302,13 @@ A floating window is created based on an existing task. It is always displayed i
### How to Develop
### How to Develop
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**
>
>
> If the task for creating the floating window is reclaimed by the system, the floating window will no longer be displayed. If you want the floating window to be displayed in such a case, apply for a [continuous task](../task-management/background-task-overview.md).
> If the task for creating the floating window is reclaimed by the system, the floating window will no longer be displayed. If you want the floating window to be displayed in such a case, apply for a [continuous task](../task-management/background-task-overview.md).
```json
```json
{
{
"module":{
"module":{
...
@@ -334,7 +326,7 @@ To create a floating window (of the **WindowType.TYPE_FLOAT** type), you must co
...
@@ -334,7 +326,7 @@ To create a floating window (of the **WindowType.TYPE_FLOAT** type), you must co
}
}
}
}
```
```
2. Create a floating window.
2. Create a floating window.
Call **window.create** to create a floating window.
Call **window.create** to create a floating window.
...
@@ -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.