提交 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
| ---------- | -------------------------- | -- | ----------------------------------- |
| name | string | Yes| Name 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.|
| 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.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type| Readable| Writable| 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**.|
| 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**.|
| Name | Type| Mandatory| Description |
| -------------------------------------- | -------- | ---- | ------------------------------------------------------------ |
| 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**.|
## Orientation<sup>9+</sup>
......@@ -248,7 +248,7 @@ Enumerates the color spaces.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Default Value | Description |
| Name | Value| Description |
| ---------- | ------ | -------------- |
| DEFAULT | 0 | Default gamut.|
| WIDE_GAMUT | 1 | Wide-gamut. |
......@@ -339,7 +339,7 @@ try {
});
} catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.createWindow<sup>9+</sup>
......@@ -386,7 +386,7 @@ try {
});
} catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.findWindow<sup>9+</sup>
......@@ -412,11 +412,12 @@ Finds a window based on the ID.
**Example**
```js
let windowClass = null;
try {
let windowClass = window.findWindow('alertWindow');
windowClass = window.findWindow('alertWindow');
} catch (exception) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.getLastWindow<sup>9+</sup>
......@@ -458,7 +459,7 @@ try {
});
} catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.getLastWindow<sup>9+</sup>
......@@ -504,7 +505,7 @@ try {
});
} catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.minimizeAll<sup>9+</sup>
......@@ -535,16 +536,12 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```js
import display from '@ohos.display'
import window from '@ohos.window'
let displayClass = null;
try {
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) => {
if(err.code) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
......@@ -552,9 +549,12 @@ try {
}
console.info('Succeeded in minimizing all windows.');
});
} catch (exception) {
} catch (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>
......@@ -590,26 +590,24 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```js
import display from '@ohos.display'
import window from '@ohos.window'
let displayClass = null;
try {
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);
promise.then(()=> {
console.info('Succeeded in minimizing all windows.');
}).catch((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));
};
}
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
```
## window.toggleShownStateForAllAppWindows<sup>9+</sup>
......@@ -644,7 +642,7 @@ window.toggleShownStateForAllAppWindows((err) => {
return;
}
console.info('Succeeded in toggling shown state for all app windows.');
})
});
```
## window.toggleShownStateForAllAppWindows<sup>9+</sup>
......@@ -678,7 +676,7 @@ promise.then(()=> {
console.info('Succeeded in toggling shown state for all app windows.');
}).catch((err)=>{
console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
})
});
```
## window.setWindowLayoutMode<sup>9+</sup>
......@@ -718,7 +716,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
};
}
```
## window.setWindowLayoutMode<sup>9+</sup>
......@@ -762,7 +760,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
};
}
```
## window.on('systemBarTintChange')<sup>8+</sup>
......@@ -778,9 +776,9 @@ Enables listening for properties changes of the status bar and navigation bar.
**Parameters**
| 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.|
| 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**
......@@ -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.
**Parameters**
| 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.|
| 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**
......@@ -818,7 +816,7 @@ try {
window.off('systemBarTintChange');
} catch (exception) {
console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
};
}
```
## window.create<sup>(deprecated)</sup>
......@@ -901,9 +899,7 @@ promise.then((data)=> {
create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
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.
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.
> **NOTE**
>
......@@ -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;
Creates a subwindow in the FA model
or a system window in the stage model. This API uses a promise to return the result.
Creates a subwindow in the FA model or a system window in the stage model. This API uses a promise to return the result.
> **NOTE**
>
......@@ -1110,7 +1104,7 @@ promise.then((data)=> {
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
});
```
## window.getTopWindow<sup>(deprecated)</sup>
......@@ -1180,7 +1174,7 @@ promise.then((data)=> {
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
});
```
## Window
......@@ -1221,8 +1215,8 @@ windowClass.hide((err) => {
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data));
})
console.info('Succeeded in hiding the window.');
});
```
### hide<sup>7+</sup>
......@@ -1257,7 +1251,7 @@ promise.then(()=> {
console.info('Succeeded in hiding the window.');
}).catch((err)=>{
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
})
});
```
### hideWithAnimation<sup>9+</sup>
......@@ -1295,7 +1289,7 @@ windowClass.hideWithAnimation((err) => {
return;
}
console.info('Succeeded in hiding the window with animation.');
})
});
```
### hideWithAnimation<sup>9+</sup>
......@@ -1329,10 +1323,10 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```js
let promise = windowClass.hideWithAnimation();
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)=>{
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
})
});
```
### showWindow<sup>9+</sup>
......@@ -1437,7 +1431,7 @@ windowClass.showWithAnimation((err) => {
return;
}
console.info('Succeeded in showing the window with animation.');
})
});
```
### showWithAnimation<sup>9+</sup>
......@@ -1474,7 +1468,7 @@ promise.then(()=> {
console.info('Succeeded in showing the window with animation.');
}).catch((err)=>{
console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
})
});
```
### destroyWindow<sup>9+</sup>
......@@ -1509,7 +1503,7 @@ windowClass.destroyWindow((err) => {
return;
}
console.info('Succeeded in destroying the window.');
})
});
```
### destroyWindow<sup>9+</sup>
......@@ -1543,7 +1537,7 @@ promise.then(()=> {
console.info('Succeeded in destroying the window.');
}).catch((err)=>{
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
})
});
```
### moveWindowTo<sup>9+</sup>
......@@ -1584,7 +1578,7 @@ try {
});
} catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
};
}
```
### moveWindowTo<sup>9+</sup>
......@@ -1629,7 +1623,7 @@ try {
});
} catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
};
}
```
### resize<sup>9+</sup>
......@@ -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.
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
**Parameters**
......@@ -1670,7 +1670,7 @@ try {
});
} catch (exception) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(exception));
};
}
```
### resize<sup>9+</sup>
......@@ -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.
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
**Parameters**
......@@ -1715,7 +1721,7 @@ try {
});
} catch (exception) {
console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowMode<sup>9+</sup>
......@@ -1758,7 +1764,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowMode<sup>9+</sup>
......@@ -1797,7 +1803,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```js
let mode = window.WindowMode.FULLSCREEN;
try {
let promise = windowClass.setWindowMode(type);
let promise = windowClass.setWindowMode(mode);
promise.then(()=> {
console.info('Succeeded in setting the window mode.');
}).catch((err)=>{
......@@ -1805,7 +1811,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
};
}
```
### getWindowProperties<sup>9+</sup>
......@@ -1837,7 +1843,7 @@ try {
let properties = windowClass.getWindowProperties();
} catch (exception) {
console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
};
}
```
### getWindowAvoidArea<sup>9+</sup>
......@@ -1876,7 +1882,7 @@ try {
let avoidArea = windowClass.getWindowAvoidArea(type);
} catch (exception) {
console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowLayoutFullScreen<sup>9+</sup>
......@@ -1917,7 +1923,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowLayoutFullScreen<sup>9+</sup>
......@@ -1962,7 +1968,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowSystemBarEnable<sup>9+</sup>
......@@ -1976,8 +1982,8 @@ Sets whether to display the status bar and navigation bar in this window. This A
**Parameters**
| 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.|
**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
**Parameters**
| 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**
......@@ -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
let SystemBarProperties={
let SystemBarProperties = {
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
let SystemBarProperties={
let SystemBarProperties = {
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
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| 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. |
**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
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| 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
let callback = ()=>{
let callback = () => {
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
import rpc from '@ohos.rpc';
class MyDeathRecipient {
onRemoteDied() {
console.log('server died');
......@@ -2824,6 +2832,7 @@ class TestRemoteObject extends rpc.RemoteObject {
return false;
}
}
let token = new TestRemoteObject('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
import rpc from '@ohos.rpc';
class MyDeathRecipient {
onRemoteDied() {
console.log('server died');
......@@ -2894,6 +2905,7 @@ class TestRemoteObject extends rpc.RemoteObject {
return false;
}
}
let token = new TestRemoteObject('testObject');
try {
let promise = windowClass.bindDialogTarget(token, () => {
......@@ -2906,7 +2918,7 @@ try {
});
} catch (exception) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
};
}
```
### isWindowSupportWideGamut<sup>9+</sup>
......@@ -3012,7 +3024,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowColorSpace<sup>9+</sup>
......@@ -3055,7 +3067,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
};
}
```
### getWindowColorSpace<sup>9+</sup>
......@@ -3116,7 +3128,7 @@ try {
windowClass.setWindowBackgroundColor(color);
} catch (exception) {
console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowBrightness<sup>9+</sup>
......@@ -3157,7 +3169,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowBrightness<sup>9+</sup>
......@@ -3202,7 +3214,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowFocusable<sup>9+</sup>
......@@ -3232,7 +3244,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example**
```js
let isFocusable= true;
let isFocusable = true;
try {
windowClass.setWindowFocusable(isFocusable, (err) => {
if (err.code) {
......@@ -3243,7 +3255,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowFocusable<sup>9+</sup>
......@@ -3278,7 +3290,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
**Example**
```js
let isFocusable= true;
let isFocusable = true;
try {
let promise = windowClass.setWindowFocusable(isFocusable);
promise.then(()=> {
......@@ -3288,7 +3300,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowKeepScreenOn<sup>9+</sup>
......@@ -3329,7 +3341,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowKeepScreenOn<sup>9+</sup>
......@@ -3374,7 +3386,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
};
}
```
### setWakeUpScreen()<sup>9+</sup>
......@@ -3410,7 +3422,7 @@ try {
windowClass.setWakeUpScreen(wakeUp);
} catch (exception) {
console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowPrivacyMode<sup>9+</sup>
......@@ -3452,7 +3464,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowPrivacyMode<sup>9+</sup>
......@@ -3498,7 +3510,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
};
}
```
### setSnapshotSkip<sup>9+</sup>
......@@ -3571,7 +3583,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowTouchable<sup>9+</sup>
......@@ -3616,7 +3628,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
};
}
```
### setForbidSplitMove<sup>9+</sup>
......@@ -3659,7 +3671,7 @@ try {
});
} catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
};
}
```
### setForbidSplitMove<sup>9+</sup>
......@@ -3706,7 +3718,7 @@ try {
});
} catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
};
}
```
### snapshot<sup>9+</sup>
......@@ -3810,7 +3822,7 @@ try {
windowClass.opacity(0.5);
} catch (exception) {
console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
};
}
```
### scale<sup>9+</sup>
......@@ -3851,7 +3863,7 @@ try {
windowClass.scale(obj);
} catch (exception) {
console.error('Failed to scale. Cause: ' + JSON.stringify(exception));
};
}
```
### rotate<sup>9+</sup>
......@@ -3893,7 +3905,7 @@ try {
windowClass.rotate(obj);
} catch (exception) {
console.error('Failed to rotate. Cause: ' + JSON.stringify(exception));
};
}
```
### translate<sup>9+</sup>
......@@ -3933,7 +3945,7 @@ try {
windowClass.translate(obj);
} catch (exception) {
console.error('Failed to translate. Cause: ' + JSON.stringify(exception));
};
}
```
### getTransitionController<sup>9+</sup>
......@@ -3986,16 +3998,16 @@ controller.animationForHidden = (context : window.TransitionContext) => {
toWindow.translate(obj); // Set the transition animation.
console.info('toWindow translate end');
}
)
);
console.info('complete transition end');
}
};
windowClass.hideWithAnimation((err, data) => {
if (err.code) {
console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
})
});
```
### setBlur<sup>9+</sup>
......@@ -4030,7 +4042,7 @@ try {
windowClass.setBlur(4.0);
} catch (exception) {
console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
};
}
```
### setBackdropBlur<sup>9+</sup>
......@@ -4065,7 +4077,8 @@ try {
windowClass.setBackdropBlur(4.0);
} catch (exception) {
console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
};
}
```
### setBackdropBlurStyle<sup>9+</sup>
......@@ -4100,7 +4113,8 @@ try {
windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
} catch (exception) {
console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
};
}
```
### setShadow<sup>9+</sup>
......@@ -4138,7 +4152,8 @@ try {
windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
} catch (exception) {
console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
};
}
```
### setCornerRadius<sup>9+</sup>
......@@ -4173,7 +4188,8 @@ try {
windowClass.setCornerRadius(4.0);
} catch (exception) {
console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
};
}
```
### show<sup>(deprecated)</sup>
......@@ -4203,7 +4219,8 @@ windowClass.show((err) => {
return;
}
console.info('Succeeded in showing the window.');
})
});
```
### show<sup>(deprecated)</sup>
......@@ -4232,7 +4249,8 @@ promise.then(()=> {
console.info('Succeeded in showing the window.');
}).catch((err)=>{
console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
})
});
```
### destroy<sup>(deprecated)</sup>
......@@ -4262,7 +4280,8 @@ windowClass.destroy((err) => {
return;
}
console.info('Succeeded in destroying the window.');
})
});
```
### destroy<sup>(deprecated)</sup>
......@@ -4291,7 +4310,8 @@ promise.then(()=> {
console.info('Succeeded in destroying the window.');
}).catch((err)=>{
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
})
});
```
### moveTo<sup>(deprecated)</sup>
......@@ -4323,8 +4343,8 @@ windowClass.moveTo(300, 300, (err)=>{
return;
}
console.info('Succeeded in moving the window.');
});
```
### moveTo<sup>(deprecated)</sup>
......@@ -4360,7 +4380,8 @@ promise.then(()=> {
console.info('Succeeded in moving the window.');
}).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
})
});
```
### resetSize<sup>(deprecated)</sup>
......@@ -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.
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**
>
> 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) => {
}
console.info('Succeeded in changing the window size.');
});
```
### resetSize<sup>(deprecated)</sup>
......@@ -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.
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**
>
> 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) => {
}
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.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
......@@ -4595,6 +4631,7 @@ windowClass.getAvoidArea(type, (err, data) => {
}
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.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
......@@ -4631,6 +4668,7 @@ promise.then((data)=> {
}).catch((err)=>{
console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
});
```
### setFullScreen<sup>(deprecated)</sup>
......@@ -4663,6 +4701,7 @@ windowClass.setFullScreen(isFullScreen, (err) => {
}
console.info('Succeeded in enabling the full-screen mode.');
});
```
### setFullScreen<sup>(deprecated)</sup>
......@@ -4769,6 +4808,7 @@ promise.then(()=> {
}).catch((err)=>{
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
});
```
### setSystemBarEnable<sup>(deprecated)</sup>
......@@ -4786,8 +4826,8 @@ Sets whether to display the status bar and navigation bar in this window. This A
**Parameters**
| 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. |
**Example**
......@@ -4820,8 +4860,8 @@ Sets whether to display the status bar and navigation bar in this window. This A
**Parameters**
| 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**
......@@ -4879,6 +4919,7 @@ windowClass.setSystemBarProperties(SystemBarProperties, (err) => {
}
console.info('Succeeded in setting the system bar properties.');
});
```
### setSystemBarProperties<sup>(deprecated)</sup>
......@@ -5020,6 +5061,7 @@ windowClass.isShowing((err, data) => {
}
console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
});
```
### isShowing<sup>(deprecated)</sup>
......@@ -5049,6 +5091,7 @@ promise.then((data)=> {
}).catch((err)=>{
console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
});
```
### on('systemAvoidAreaChange')<sup>(deprecated)</sup>
......@@ -5076,6 +5119,7 @@ Enables listening for changes to the area where the window cannot be displayed.
windowClass.on('systemAvoidAreaChange', (data) => {
console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
});
```
### off('systemAvoidAreaChange')<sup>(deprecated)</sup>
......@@ -5131,7 +5175,7 @@ windowClass.isSupportWideGamut((err, data) => {
return;
}
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) => {
return;
}
console.info('Succeeded in setting window colorspace.');
})
});
```
### setColorSpace<sup>(deprecated)</sup>
......@@ -5259,7 +5304,7 @@ windowClass.getColorSpace((err, data) => {
return;
}
console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
})
});
```
......@@ -5323,6 +5368,7 @@ windowClass.setBackgroundColor(color, (err) => {
}
console.info('Succeeded in setting the background color.');
});
```
### setBackgroundColor<sup>(deprecated)</sup>
......@@ -5461,6 +5507,7 @@ windowClass.setDimBehind(0.5, (err) => {
}
console.info('Succeeded in setting the dimness.');
});
```
### setDimBehind<sup>(deprecated)</sup>
......@@ -5566,6 +5613,7 @@ promise.then(()=> {
}).catch((err)=>{
console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
});
```
### setKeepScreenOn<sup>(deprecated)</sup>
......@@ -5598,6 +5646,7 @@ windowClass.setKeepScreenOn(isKeepScreenOn, (err) => {
}
console.info('Succeeded in setting the screen to be always on.');
});
```
### setKeepScreenOn<sup>(deprecated)</sup>
......@@ -5634,6 +5683,7 @@ promise.then(() => {
}).catch((err)=>{
console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
});
```
### setOutsideTouchable<sup>(deprecated)</sup>
......@@ -5664,7 +5714,8 @@ windowClass.setOutsideTouchable(true, (err) => {
return;
}
console.info('Succeeded in setting the area to be touchable.');
})
});
```
### setOutsideTouchable<sup>(deprecated)</sup>
......@@ -5700,6 +5751,7 @@ promise.then(()=> {
}).catch((err)=>{
console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
});
```
### setPrivacyMode<sup>(deprecated)</sup>
......@@ -5731,7 +5783,6 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => {
return;
}
console.info('Succeeded in setting the window to privacy mode.');
});
```
......@@ -5770,6 +5821,7 @@ promise.then(()=> {
}).catch((err)=>{
console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
});
```
### setTouchable<sup>(deprecated)</sup>
......@@ -5801,8 +5853,8 @@ windowClass.setTouchable(isTouchable, (err) => {
return;
}
console.info('Succeeded in setting the window to be touchable.');
});
```
### setTouchable<sup>(deprecated)</sup>
......@@ -5839,6 +5891,7 @@ promise.then(()=> {
}).catch((err)=>{
console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
});
```
## WindowStageEventType<sup>9+</sup>
......@@ -5849,8 +5902,8 @@ Describes the lifecycle of a window stage.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Default Value | Description |
| ---------- | ------------- | ---------------------------------------------- |
| Name | Value | Description |
| ---------- | ----- | ---------------------------------------------- |
| FOREGROUND | 1 | The window stage is running in the foreground. |
| ACTIVE | 2 | The window stage gains focus. |
| INACTIVE | 3 | The window stage loses focus. |
......@@ -5891,6 +5944,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -5904,7 +5958,8 @@ class myAbility extends Ability {
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
});
}
}
};
```
### getMainWindow<sup>9+</sup>
......@@ -5936,19 +5991,21 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
let windowClass = null;
let promise = windowStage.getMainWindow();
promise.then((data)=> {
promise.then((data) => {
windowClass = 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));
});
}
}
};
```
### getMainWindowSync<sup>9+</sup>
......@@ -5980,6 +6037,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -5989,7 +6047,8 @@ class myAbility extends Ability {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
};
}
}
};
```
### createSubWindow<sup>9+</sup>
......@@ -6006,7 +6065,7 @@ Creates a subwindow for this window stage. This API uses an asynchronous callbac
| 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. |
**Error codes**
......@@ -6022,6 +6081,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6040,7 +6100,8 @@ class myAbility extends Ability {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
};
}
}
};
```
### createSubWindow<sup>9+</sup>
......@@ -6057,7 +6118,7 @@ Creates a subwindow for this window stage. This API uses a promise to return the
| Name | Type | Mandatory | Description |
| ---- | ------ | --------- | ---------------------- |
| name | String | Yes | Name of the subwindow. |
| name | string | Yes | Name of the subwindow. |
**Return value**
......@@ -6078,23 +6139,25 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
let windowClass = null;
try {
let promise = windowStage.createSubWindow('mySubWindow');
promise.then((data)=> {
promise.then((data) => {
windowClass = 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));
});
} catch (exception) {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
};
}
}
};
```
### getSubWindow<sup>9+</sup>
......@@ -6125,6 +6188,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6138,7 +6202,8 @@ class myAbility extends Ability {
console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
});
}
}
};
```
### getSubWindow<sup>9+</sup>
......@@ -6169,19 +6234,21 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
let windowClass = null;
let promise = windowStage.getSubWindow();
promise.then((data)=> {
promise.then((data) => {
windowClass = 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));
})
}
}
};
```
### loadContent<sup>9+</sup>
......@@ -6199,7 +6266,7 @@ Loads content from a page associated with a local storage to the main window in
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
| 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. |
**Error codes**
......@@ -6215,6 +6282,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
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
| Name | Type | Mandatory | Description |
| ------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
| 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
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
storage : LocalStorage
onWindowStageCreate(windowStage) {
......@@ -6280,16 +6350,17 @@ class myAbility extends Ability {
console.log('onWindowStageCreate');
try {
let promise = windowStage.loadContent('pages/page2',this.storage);
promise.then(()=> {
promise.then(() => {
console.info('Succeeded in loading the content.');
}).catch((err)=>{
}).catch((err) => {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
}
};
```
### loadContent<sup>9+</sup>
......@@ -6322,6 +6393,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6337,7 +6409,8 @@ class myAbility extends Ability {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
}
};
```
### on('windowStageEvent')<sup>9+</sup>
......@@ -6370,6 +6443,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6383,7 +6457,8 @@ class myAbility extends Ability {
JSON.stringify(exception));
};
}
}
};
```
### off('windowStageEvent')<sup>9+</sup>
......@@ -6416,6 +6491,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6426,7 +6502,8 @@ class myAbility extends Ability {
JSON.stringify(exception));
};
}
}
};
```
### disableWindowDecor()<sup>9+</sup>
......@@ -6454,12 +6531,14 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('disableWindowDecor');
windowStage.disableWindowDecor();
}
}
};
```
### setShowOnLockScreen()<sup>9+</sup>
......@@ -6493,6 +6572,7 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6502,7 +6582,8 @@ class myAbility extends Ability {
console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
};
}
}
};
```
## TransitionContext<sup>9+</sup>
......@@ -6557,7 +6638,7 @@ controller.animationForShown = (context : window.TransitionContext) => {
toWindow.translate(obj);
console.info('toWindow translate end');
}
)
);
try {
context.completeTransition(true)
} catch (exception) {
......@@ -6565,6 +6646,7 @@ controller.animationForShown = (context : window.TransitionContext) => {
}
console.info('complete transition end');
};
```
## TransitionController<sup>9+</sup>
......@@ -6612,9 +6694,10 @@ controller.animationForShown = (context : window.TransitionContext) => {
toWindow.translate(obj);
console.info('toWindow translate end');
}
)
);
console.info('complete transition end');
}
};
```
### animationForHidden<sup>9+</sup>
......@@ -6660,6 +6743,5 @@ controller.animationForHidden = (context : window.TransitionContext) => {
}
)
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
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.
......@@ -83,21 +84,21 @@ class MainAbility extends Ability {
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
// 2. Set the touchable property of the main window.
let isTouchable = true;
windowClass.setTouchable(isTouchable, (err, data) => {
windowClass.setTouchable(isTouchable, (err) => {
if (err.code) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));
console.info('Succeeded in setting the window to be touchable.');
})
})
// 3. Load the page content to the main window.
windowStage.loadContent("pages/page2", (err, data) => {
windowStage.loadContent("pages/page2", (err) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
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
### 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.
......@@ -144,44 +144,35 @@ Call **getSubWindow** to obtain a subwindow.
}
sub_windowClass = 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.
sub_windowClass.moveTo(300, 300, (err, data) => {
sub_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.');
});
sub_windowClass.resetSize(500, 1000, (err, data) => {
sub_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.');
});
// 3. Load the page content to the subwindow.
sub_windowClass.loadContent("pages/page3", (err, data) => {
sub_windowClass.loadContent("pages/page3", (err) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
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.
let isFullScreen = true;
windowClass.setFullScreen(isFullScreen, (err, data) => {
windowClass.setFullScreen(isFullScreen, (err) => {
if (err.code) {
console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
console.info('Succeeded in enabling the full-screen mode.');
});
// 2. Use method 2 to implement the immersive effect.
let names = [];
windowClass.setSystemBarEnable(names, (err, data) => {
windowClass.setSystemBarEnable(names, (err) => {
if (err.code) {
console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
console.info('Succeeded in setting the system bar to be visible.');
});
// 2. Use method 3 to implement the immersive effect.
let isLayoutFullScreen = true;
windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
windowClass.setLayoutFullScreen(isLayoutFullScreen, (err) => {
if (err.code) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
console.info('Succeeded in setting the window layout to full-screen mode.');
});
let sysBarProps = {
statusBarColor: '#ff00ff',
......@@ -281,21 +273,21 @@ Call **getMainWindow** to obtain the main window of the application.
statusBarContentColor: '#ffffff',
navigationBarContentColor: '#ffffff'
};
windowClass.setSystemBarProperties(sysBarProps, (err, data) => {
windowClass.setSystemBarProperties(sysBarProps, (err) => {
if (err.code) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
console.info('Succeeded in setting the system bar properties.');
});
})
// 3. Load the page content to the immersive window.
windowStage.loadContent("pages/page2", (err, data) => {
windowStage.loadContent("pages/page2", (err) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
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.
windowClass.loadContent("pages/page4", (err, data) => {
windowClass.loadContent("pages/page4", (err) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
console.info('Succeeded in loading the content.');
// 4. Show the floating window.
windowClass.show((err, data) => {
windowClass.show((err) => {
if (err.code) {
console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
console.info('Succeeded in showing the window.');
});
});
// 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) {
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.');
});
});
}
......
......@@ -65,46 +65,46 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
console.info('Succeeded in creating the volume window.')
windowClass = data;
// 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) {
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.');
});
// 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) {
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 volume bar window.
windowClass.show((err, data) => {
windowClass.show((err) => {
if (err.code) {
console.error('Failed to show the window. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
console.info('Succeeded in showing the window.');
});
});
// 4. Hide or destroy the volume bar window.
// Hide the volume bar window when a click event outside the window is detected.
windowClass.on('touchOutside', () => {
console.info('touch outside');
windowClass.hide((err, data) => {
windowClass.hide((err) => {
if (err.code) {
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
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.
## 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.
先完成此消息的编辑!
想要评论请 注册