| 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.|
| 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.
| 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**.|
| 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**.|
| 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**.|
| 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**.|
| 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**.|
| 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**.|
| 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 | 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 | 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 | 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 | 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 | 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.|
| 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**
...
...
@@ -791,7 +789,7 @@ try {
});
}catch(exception){
console.error('Failed to enable the listener for systemBarTint changes. Cause: '+JSON.stringify(exception));
};
}
```
## window.off('systemBarTintChange')<sup>8+</sup>
...
...
@@ -807,9 +805,9 @@ 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.|
| 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**
...
...
@@ -818,7 +816,7 @@ try {
window.off('systemBarTintChange');
}catch(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.|
**Error codes**
...
...
@@ -2004,7 +2010,7 @@ try {
});
}catch(exception){
console.error('Failed to set the system bar to be invisible. Cause:'+JSON.stringify(exception));
};
}
```
### setWindowSystemBarEnable<sup>9+</sup>
...
...
@@ -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**
...
...
@@ -2050,7 +2056,7 @@ try {
});
}catch(exception){
console.error('Failed to set the system bar to be invisible. Cause:'+JSON.stringify(exception));
};
}
```
### setWindowSystemBarProperties<sup>9+</sup>
...
...
@@ -2080,7 +2086,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example**
```js
letSystemBarProperties={
letSystemBarProperties={
statusBarColor:'#ff00ff',
navigationBarColor:'#00ff00',
// The following properties are supported since API version 8.
...
...
@@ -2097,7 +2103,7 @@ try {
});
}catch(exception){
console.error('Failed to set the system bar properties. Cause: '+JSON.stringify(exception));
};
}
```
### setWindowSystemBarProperties<sup>9+</sup>
...
...
@@ -2132,7 +2138,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example**
```js
letSystemBarProperties={
letSystemBarProperties={
statusBarColor:'#ff00ff',
navigationBarColor:'#00ff00',
// The following properties are supported since API version 8.
...
...
@@ -2148,7 +2154,7 @@ try {
});
}catch(exception){
console.error('Failed to set the system bar properties. Cause: '+JSON.stringify(exception));
};
}
```
### setPreferredOrientation<sup>9+</sup>
...
...
@@ -2188,7 +2194,7 @@ try {
});
}catch(exception){
console.error('Failed to set window orientation. Cause: '+JSON.stringify(exception));
};
}
```
### setPreferredOrientation<sup>9+</sup>
...
...
@@ -2232,7 +2238,7 @@ try {
});
}catch(exception){
console.error('Failed to set window orientation. Cause: '+JSON.stringify(exception));
};
}
```
### setUIContent<sup>9+</sup>
...
...
@@ -2272,7 +2278,7 @@ try {
});
}catch(exception){
console.error('Failed to load the content. Cause:'+JSON.stringify(exception));
};
}
```
### setUIContent<sup>9+</sup>
...
...
@@ -2316,7 +2322,7 @@ try {
});
}catch(exception){
console.error('Failed to load the content. Cause: '+JSON.stringify(exception));
};
}
```
### loadContent<sup>9+</sup>
...
...
@@ -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. |
| 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. |
**Error codes**
...
...
@@ -2362,7 +2368,7 @@ try {
});
}catch(exception){
console.error('Failed to load the content. Cause:'+JSON.stringify(exception));
};
}
```
### loadContent<sup>9+</sup>
...
...
@@ -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. |
| 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**
...
...
@@ -2412,7 +2418,7 @@ try {
});
}catch(exception){
console.error('Failed to load the content. Cause:'+JSON.stringify(exception));
};
}
```
### isWindowShowing<sup>9+</sup>
...
...
@@ -2445,7 +2451,7 @@ try {
console.info('Succeeded in checking whether the window is showing. Data: '+JSON.stringify(data));
}catch(exception){
console.error('Failed to check whether the window is showing. Cause: '+JSON.stringify(exception));
};
}
```
### on('windowSizeChange')<sup>7+</sup>
...
...
@@ -2472,7 +2478,7 @@ try {
});
}catch(exception){
console.error('Failed to enable the listener for window size changes. Cause: '+JSON.stringify(exception));
};
}
```
### off('windowSizeChange')<sup>7+</sup>
...
...
@@ -2497,7 +2503,7 @@ try {
windowClass.off('windowSizeChange');
}catch(exception){
console.error('Failed to disable the listener for window size changes. Cause: '+JSON.stringify(exception));
};
}
```
### on('avoidAreaChange')<sup>9+</sup>
...
...
@@ -2525,7 +2531,7 @@ try {
});
}catch(exception){
console.error('Failed to enable the listener for system avoid area changes. Cause: '+JSON.stringify(exception));
};
}
```
### off('avoidAreaChange')<sup>9+</sup>
...
...
@@ -2550,7 +2556,7 @@ try {
windowClass.off('avoidAreaChange');
}catch(exception){
console.error('Failed to disable the listener for system avoid area changes. Cause: '+JSON.stringify(exception));
};
}
```
### on('keyboardHeightChange')<sup>7+</sup>
...
...
@@ -2577,7 +2583,7 @@ try {
});
}catch(exception){
console.error('Failed to enable the listener for keyboard height changes. Cause: '+JSON.stringify(exception));
};
}
```
### off('keyboardHeightChange')<sup>7+</sup>
...
...
@@ -2602,7 +2608,7 @@ try {
windowClass.off('keyboardHeightChange');
}catch(exception){
console.error('Failed to disable the listener for keyboard height changes. Cause: '+JSON.stringify(exception));
};
}
```
### on('touchOutside')<sup>9+</sup>
...
...
@@ -2631,7 +2637,7 @@ try {
});
}catch(exception){
console.error('Failed to register callback. Cause: '+JSON.stringify(exception));
};
}
```
### off('touchOutside')<sup>9+</sup>
...
...
@@ -2658,7 +2664,7 @@ try {
windowClass.off('touchOutside');
}catch(exception){
console.error('Failed to unregister callback. Cause: '+JSON.stringify(exception));
};
}
```
### on('screenshot')<sup>9+</sup>
...
...
@@ -2685,7 +2691,7 @@ try {
});
}catch(exception){
console.error('Failed to register callback. Cause: '+JSON.stringify(exception));
};
}
```
### off('screenshot')<sup>9+</sup>
...
...
@@ -2706,21 +2712,21 @@ Unsubscribes from screenshot events.
**Example**
```js
letcallback=()=>{
letcallback=()=>{
console.info('screenshot happened');
};
try{
windowClass.on('screenshot',callback);
}catch(exception){
console.error('Failed to register callback. Cause: '+JSON.stringify(exception));
};
}
try{
windowClass.off('screenshot',callback);
// If multiple callbacks are enabled in on(), they will all be disabled.
windowClass.off('screenshot');
}catch(exception){
console.error('Failed to unregister callback. Cause: '+JSON.stringify(exception));
};
}
```
### on('dialogTargetTouch')<sup>9+</sup>
...
...
@@ -2747,7 +2753,7 @@ try {
});
}catch(exception){
console.error('Failed to register callback. Cause: '+JSON.stringify(exception));
};
}
```
### off('dialogTargetTouch')<sup>9+</sup>
...
...
@@ -2772,7 +2778,7 @@ try {
windowClass.off('dialogTargetTouch');
}catch(exception){
console.error('Failed to unregister callback. Cause: '+JSON.stringify(exception));
};
}
```
### bindDialogTarget<sup>9+</sup>
...
...
@@ -2805,6 +2811,8 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example**
```js
importrpcfrom'@ohos.rpc';
classMyDeathRecipient{
onRemoteDied(){
console.log('server died');
...
...
@@ -2824,6 +2832,7 @@ class TestRemoteObject extends rpc.RemoteObject {
returnfalse;
}
}
lettoken=newTestRemoteObject('testObject');
try{
windowClass.bindDialogTarget(token,()=>{
...
...
@@ -2837,7 +2846,7 @@ try {
});
}catch(exception){
console.error('Failed to bind dialog target. Cause:'+JSON.stringify(exception));
};
}
```
### bindDialogTarget<sup>9+</sup>
...
...
@@ -2875,6 +2884,8 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example**
```js
importrpcfrom'@ohos.rpc';
classMyDeathRecipient{
onRemoteDied(){
console.log('server died');
...
...
@@ -2894,6 +2905,7 @@ class TestRemoteObject extends rpc.RemoteObject {
console.info('Succeeded in setting the window type.');
});
```
### setWindowType<sup>(deprecated)</sup>
...
...
@@ -4502,6 +4537,7 @@ promise.then(()=> {
}).catch((err)=>{
console.error('Failed to set the window type. Cause: '+JSON.stringify(err));
});
```
### getProperties<sup>(deprecated)</sup>
...
...
@@ -4573,7 +4609,7 @@ Obtains the area where this window cannot be displayed, for example, the system
> **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));
});
```
### getAvoidArea<sup>(deprecated)</sup>
...
...
@@ -4605,7 +4642,7 @@ Obtains the area where this window cannot be displayed, for example, the system
> **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. |
**Example**
...
...
@@ -4820,8 +4860,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. |
| 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. |
**Error codes**
...
...
@@ -6215,6 +6282,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
importAbilityfrom'@ohos.application.Ability';
classmyAbilityextendsAbility{
storage:LocalStorage
onWindowStageCreate(windowStage){
...
...
@@ -6233,7 +6301,8 @@ class myAbility extends Ability {
console.error('Failed to load the content. Cause:'+JSON.stringify(exception));
};
}
}
};
```
### loadContent<sup>9+</sup>
...
...
@@ -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. |
| 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**
...
...
@@ -6272,6 +6341,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
importAbilityfrom'@ohos.application.Ability';
classmyAbilityextendsAbility{
storage:LocalStorage
onWindowStageCreate(windowStage){
...
...
@@ -6280,16 +6350,17 @@ class myAbility extends Ability {
console.error('Failed to load the content. Cause:'+JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: '+JSON.stringify(data));
console.info('Succeeded in loading the content.');
// 3. Show the subwindow.
sub_windowClass.show((err,data)=>{
sub_windowClass.show((err)=>{
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;
}
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.
destroySubWindow(){
// 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){
console.error('Failed to destroy the window. Cause: '+JSON.stringify(err));
return;
}
console.info('Succeeded in destroying the window. Data: '+JSON.stringify(data));
console.info('Succeeded in destroying the window.');
});
}
onWindowStageCreate(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();
}
...
...
@@ -221,7 +212,8 @@ To create a better video watching and gaming experience, you can use the immersi
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:
- 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.
// 2. Use method 1 to implement the immersive effect.
console.error('Failed to load the content. Cause:'+JSON.stringify(err));
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
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**
>
...
...
@@ -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));
windowClass=data;
// 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){
console.error('Failed to move the window. Cause:'+JSON.stringify(err));
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){
console.error('Failed to change the window size. Cause:'+JSON.stringify(err));
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.