提交 650b0404 编写于 作者: E ester.zhou

Update docs (21948)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 e74c074b
...@@ -265,7 +265,7 @@ Text($r('app.string.message_arrive', "five of the clock")) ...@@ -265,7 +265,7 @@ Text($r('app.string.message_arrive', "five of the clock"))
.fontColor($r('app.color.color_hello')) .fontColor($r('app.color.color_hello'))
.fontSize($r('app.float.font_hello')) .fontSize($r('app.float.font_hello'))
// Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, **one** indicates singular and is represented by **1**, and **other** indicates plural and is represented by an integer greater than or equal to 1; for Chinese, **other** indicates both singular and plural), and the third parameter is used to replace %d. // Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, one indicates singular and is represented by 1, and other indicates plural and is represented by an integer greater than or equal to 1; for Chinese, other indicates both singular and plural), and the third parameter is used to replace %d.
// In this example, the resultant value is "5 apples". // In this example, the resultant value is "5 apples".
Text($r('app.plural.eat_apple', 5, 5)) Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world')) .fontColor($r('app.color.color_world'))
......
...@@ -31,8 +31,8 @@ import config from '@ohos.accessibility.config'; ...@@ -31,8 +31,8 @@ import config from '@ohos.accessibility.config';
| shortkeyTarget | [Config](#config)\<string>| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is 'bundleName/abilityName'.| | shortkeyTarget | [Config](#config)\<string>| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is 'bundleName/abilityName'.|
| captions | [Config](#config)\<boolean>| Yes| Yes| Whether to enable captions.| | captions | [Config](#config)\<boolean>| Yes| Yes| Whether to enable captions.|
| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](js-apis-accessibility.md#captionsstyle8)>| Yes| Yes| Captions style.| | captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](js-apis-accessibility.md#captionsstyle8)>| Yes| Yes| Captions style.|
| audioMono| [Config](#config)\<boolean>| Yes| Yes| Whether to enable mono audio. The value **True** means to enable mono audio, and **False** means the opposite.| | audioMono<sup>10+</sup>| [Config](#config)\<boolean>| Yes| Yes| Whether to enable mono audio. The value **True** means to enable mono audio, and **False** means the opposite.|
| audioBalance| [Config](#config)\<number>| Yes| Yes| Audio balance for the left and right audio channels. The value ranges from -1.0 to 1.0.| | audioBalance<sup>10+</sup>| [Config](#config)\<number>| Yes| Yes| Audio balance for the left and right audio channels. The value ranges from -1.0 to 1.0.|
## enableAbility ## enableAbility
......
...@@ -18,15 +18,15 @@ import InputMethodSubtype from '@ohos.InputMethodSubtype'; ...@@ -18,15 +18,15 @@ import InputMethodSubtype from '@ohos.InputMethodSubtype';
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name| Type| Readable| Writable| Mandatory| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| label | string | Yes| No| No| Label of the input method subtype.| | label | string | Yes| No| Optional. Label of the input method subtype.|
| labelId<sup>10+</sup> | string | Yes| No| No| Label ID of the input method subtype.| | labelId<sup>10+</sup> | string | Yes| No| Optional. Label ID of the input method subtype.|
| name | string | Yes| No| Yes| Bundle name of the input method.| | name | string | Yes| No| Mandatory. Bundle name of the input method.|
| id | string | Yes| No| Yes| ID of the input method subtype.| | id | string | Yes| No| Mandatory. ID of the input method subtype.|
| mode | string | Yes| No| No| Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).| | mode | string | Yes| No| Optional. Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).|
| locale | string | Yes| No| Yes| Locale of the input method subtype.| | locale | string | Yes| No| Mandatory. Locale of the input method subtype.|
| language | string | Yes| No| Yes| Language of the input method subtype.| | language | string | Yes| No| Mandatory. Language of the input method subtype.|
| icon | string | Yes| No| No| Icon of the input method subtype.| | icon | string | Yes| No| Optional. Icon of the input method subtype. It can be obtained by using **iconId**. This parameter is reserved.|
| iconId | number | Yes| No| No| Icon ID of the input method subtype.| | iconId | number | Yes| No| Optional. Icon ID of the input method subtype.|
| extra | object | Yes| Yes| No| Extra information of the input method subtype.<br>**NOTE**<br>This parameter is optional since API version 10.| | extra | object | Yes| Yes| Optional. Extra information of the input method subtype. This parameter is reserved and currently has no specific meaning.<br>**NOTE**<br>This parameter is optional since API version 10.|
...@@ -35,9 +35,9 @@ Describes the input method application attributes. ...@@ -35,9 +35,9 @@ Describes the input method application attributes.
| id<sup>9+</sup> | string | Yes| No| Mandatory. Unique ID of the input method.| | id<sup>9+</sup> | string | Yes| No| Mandatory. Unique ID of the input method.|
| label<sup>9+</sup> | string | Yes| No| Optional. External name of the input method.| | label<sup>9+</sup> | string | Yes| No| Optional. External name of the input method.|
| labelId<sup>10+</sup> | string | Yes| No| Optional. External ID of the input method.| | labelId<sup>10+</sup> | string | Yes| No| Optional. External ID of the input method.|
| icon<sup>9+</sup> | string | Yes| No| Optional. Icon of the input method.| | icon<sup>9+</sup> | string | Yes| No| Optional. Icon of the input method. It can be obtained by using **iconId**. This parameter is reserved.|
| iconId<sup>9+</sup> | number | Yes| No| Optional. Icon ID of the input method.| | iconId<sup>9+</sup> | number | Yes| No| Optional. Icon ID of the input method.|
| extra<sup>9+</sup> | object | Yes| Yes| Extra information about the input method.<br>- API version 10 and later: optional<br>- API version 9: mandatory| | extra<sup>9+</sup> | object | Yes| Yes| Extra information about the input method. This parameter is reserved and currently has no specific meaning.<br>- API version 10 and later: optional<br>- API version 9: mandatory|
| packageName<sup>(deprecated)</sup> | string | Yes| No| Name of the input method package. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **name**.| | packageName<sup>(deprecated)</sup> | string | Yes| No| Name of the input method package. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **name**.|
| methodId<sup>(deprecated)</sup> | string | Yes| No| Unique ID of the input method. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **id**.| | methodId<sup>(deprecated)</sup> | string | Yes| No| Unique ID of the input method. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **id**.|
...@@ -154,15 +154,15 @@ Switches to another input method. This API uses a promise to return the result. ...@@ -154,15 +154,15 @@ Switches to another input method. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
|target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.| |target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------- | ---------------------------- | | ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.| | Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
**Error codes** **Error codes**
...@@ -606,9 +606,12 @@ Describes the configuration of the editor component. When the editor component r ...@@ -606,9 +606,12 @@ Describes the configuration of the editor component. When the editor component r
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name| Type| Readable| Writable| Description| | Name| Type| Read-only| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| inputAttribute<sup>10+</sup> | [InputAttribute](#inputattribute10) | Yes| Yes| Edit box attribute.| | inputAttribute<sup>10+</sup> | [InputAttribute](#inputattribute10) | No| Yes| Edit box attribute.|
| cursorInfo<sup>10+</sup> | [CursorInfo](#cursorinfo10) | No| No| Cursor information.|
| selection<sup>10+</sup> | [Range](#range10) | No| No| Text selection range.|
| windowId<sup>10+</sup> | number | No| No| ID of the window where the editor component is located.|
## CursorInfo<sup>10+</sup> ## CursorInfo<sup>10+</sup>
...@@ -1684,7 +1687,7 @@ try { ...@@ -1684,7 +1687,7 @@ try {
### off('insertText')<sup>10+</sup> ### off('insertText')<sup>10+</sup>
off(type: 'insertText'): void off(type: 'insertText', callback?: (text: string) => void): void
Disables listening for the text insertion event of the input method. Disables listening for the text insertion event of the input method.
...@@ -1692,13 +1695,18 @@ Disables listening for the text insertion event of the input method. ...@@ -1692,13 +1695,18 @@ Disables listening for the text insertion event of the input method.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'insertText'** indicates the text insertion event.| | type | string | Yes | Listening type.<br>The value **'insertText'** indicates the text insertion event.|
| callback | (text: string) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example** **Example**
```js ```js
let onInsertTextCallback = (text: string) => {
console.log(`Succeeded in subscribing insertText: ${text}`);
};
inputMethodController.off('insertText', onInsertTextCallback);
inputMethodController.off('insertText'); inputMethodController.off('insertText');
``` ```
...@@ -1773,7 +1781,7 @@ try { ...@@ -1773,7 +1781,7 @@ try {
``` ```
### off('deleteLeft')<sup>10+</sup> ### off('deleteLeft')<sup>10+</sup>
off(type: 'deleteLeft'): void off(type: 'deleteLeft', callback?: (length: number) => void): void
Disables listening for the backward delete event. Disables listening for the backward delete event.
...@@ -1781,19 +1789,24 @@ Disables listening for the backward delete event. ...@@ -1781,19 +1789,24 @@ Disables listening for the backward delete event.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'deleteLeft'** indicates the backward delete event.| | type | string | Yes | Listening type.<br>The value **'deleteLeft'** indicates the backward delete event.|
| callback | (length: number) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example** **Example**
```js ```js
let onDeleteLeftCallback = (length: number) => {
console.log(`Succeeded in subscribing deleteLeft, length: ${length}`);
};
inputMethodController.off('deleteLeft', onDeleteLeftCallback);
inputMethodController.off('deleteLeft'); inputMethodController.off('deleteLeft');
``` ```
### off('deleteRight')<sup>10+</sup> ### off('deleteRight')<sup>10+</sup>
off(type: 'deleteRight'): void off(type: 'deleteRight', callback?: (length: number) => void): void
Disables listening for the forward delete event. Disables listening for the forward delete event.
...@@ -1801,19 +1814,24 @@ Disables listening for the forward delete event. ...@@ -1801,19 +1814,24 @@ Disables listening for the forward delete event.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'deleteRight'** indicates the forward delete event.| | type | string | Yes | Listening type.<br>The value **'deleteRight'** indicates the forward delete event.|
| callback | (length: number) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example** **Example**
```js ```js
let onDeleteRightCallback = (length: number) => {
console.log(`Succeeded in subscribing deleteRight, length: ${length}`);
};
inputMethodController.off('deleteRight', onDeleteRightCallback);
inputMethodController.off('deleteRight'); inputMethodController.off('deleteRight');
``` ```
### on('sendKeyboardStatus')<sup>10+</sup> ### on('sendKeyboardStatus')<sup>10+</sup>
on(type: 'sendKeyboardStatus', callback: (keyBoardStatus: KeyboardStatus) => void): void on(type: 'sendKeyboardStatus', callback: (keyboardStatus: KeyboardStatus) => void): void
Enables listening for the keyboard status event of the input method. This API uses an asynchronous callback to return the result. Enables listening for the keyboard status event of the input method. This API uses an asynchronous callback to return the result.
...@@ -1824,7 +1842,7 @@ Enables listening for the keyboard status event of the input method. This API us ...@@ -1824,7 +1842,7 @@ Enables listening for the keyboard status event of the input method. This API us
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| type | string | Yes | Listening type.<br>The value **'sendKeyboardStatus'** indicates the keyboard status event.| | type | string | Yes | Listening type.<br>The value **'sendKeyboardStatus'** indicates the keyboard status event.|
| callback | (keyBoardStatus: [KeyboardStatus](#keyboardstatus10)) => void | Yes | Callback used to return the keyboard status.<br>Your application needs to perform operations based on the keyboard state returned in the callback.| | callback | (keyboardStatus: [KeyboardStatus](#keyboardstatus10)) => void | Yes | Callback used to return the keyboard status.<br>Your application needs to perform operations based on the keyboard state returned in the callback.|
**Error codes** **Error codes**
...@@ -1838,8 +1856,8 @@ For details about the error codes, see [Input Method Framework Error Codes](../e ...@@ -1838,8 +1856,8 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
```js ```js
try { try {
inputMethodController.on('sendKeyboardStatus', (keyBoardStatus) => { inputMethodController.on('sendKeyboardStatus', (keyboardStatus) => {
console.log(`Succeeded in subscribing sendKeyboardStatus, keyBoardStatus: ${keyBoardStatus}`); console.log(`Succeeded in subscribing sendKeyboardStatus, keyboardStatus: ${keyboardStatus}`);
}); });
} catch(err) { } catch(err) {
console.error(`Failed to subscribe sendKeyboardStatus: ${JSON.stringify(err)}`); console.error(`Failed to subscribe sendKeyboardStatus: ${JSON.stringify(err)}`);
...@@ -1848,7 +1866,7 @@ try { ...@@ -1848,7 +1866,7 @@ try {
### off('sendKeyboardStatus')<sup>10+</sup> ### off('sendKeyboardStatus')<sup>10+</sup>
off(type: 'sendKeyboardStatus'): void off(type: 'sendKeyboardStatus', callback?: (keyboardStatus: KeyboardStatus) => void): void
Disables listening for the keyboard status event of the input method. Disables listening for the keyboard status event of the input method.
...@@ -1856,13 +1874,18 @@ Disables listening for the keyboard status event of the input method. ...@@ -1856,13 +1874,18 @@ Disables listening for the keyboard status event of the input method.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'sendKeyboardStatus'** indicates the keyboard status event.| | type | string | Yes | Listening type.<br>The value **'sendKeyboardStatus'** indicates the keyboard status event.|
| callback | (keyboardStatus: [KeyboardStatus](#keyboardstatus10)) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example** **Example**
```js ```js
let onSendKeyboardStatus = (keyboardStatus: KeyboardStatus) => {
console.log(`Succeeded in subscribing sendKeyboardStatus, keyboardStatus: ${keyboardStatus}`);
};
inputMethodController.off('sendKeyboardStatus', onSendKeyboardStatus);
inputMethodController.off('sendKeyboardStatus'); inputMethodController.off('sendKeyboardStatus');
``` ```
...@@ -1903,7 +1926,7 @@ try { ...@@ -1903,7 +1926,7 @@ try {
### off('sendFunctionKey')<sup>10+</sup> ### off('sendFunctionKey')<sup>10+</sup>
off(type: 'sendFunctionKey'): void off(type: 'sendFunctionKey', callback?: (functionKey: FunctionKey) => void): void
Disables listening for the function key sending event of the input method. Disables listening for the function key sending event of the input method.
...@@ -1911,13 +1934,18 @@ Disables listening for the function key sending event of the input method. ...@@ -1911,13 +1934,18 @@ Disables listening for the function key sending event of the input method.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'sendFunctionKey'** indicates the function key sending event.| | type | string | Yes | Listening type.<br>The value **'sendFunctionKey'** indicates the function key sending event.|
| callback | (functionKey: [FunctionKey](#functionkey10)) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example** **Example**
```js ```js
let onSendFunctionKey = (functionKey: FunctionKey) => {
console.log(`Succeeded in subscribing sendFunctionKey, functionKey: ${functionKey.enterKeyType}`);
};
inputMethodController.off('sendFunctionKey', onSendFunctionKey);
inputMethodController.off('sendFunctionKey'); inputMethodController.off('sendFunctionKey');
``` ```
...@@ -1958,7 +1986,7 @@ try { ...@@ -1958,7 +1986,7 @@ try {
### off('moveCursor')<sup>10+</sup> ### off('moveCursor')<sup>10+</sup>
off(type: 'moveCursor'): void off(type: 'moveCursor', callback?: (direction: Direction) => void): void
Disables listening for the cursor movement event of the input method. Disables listening for the cursor movement event of the input method.
...@@ -1969,10 +1997,15 @@ Disables listening for the cursor movement event of the input method. ...@@ -1969,10 +1997,15 @@ Disables listening for the cursor movement event of the input method.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ---- | | ------ | ------ | ---- | ---- |
| type | string | Yes | Listening type.<br>The value **'moveCursor'** indicates the cursor movement event.| | type | string | Yes | Listening type.<br>The value **'moveCursor'** indicates the cursor movement event.|
| callback | (direction: [Direction<sup>10+</sup>](#direction10)) => void | No| Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example** **Example**
```js ```js
let onMoveCursorCallback = (direction: Direction) => {
console.log(`Succeeded in subscribing moveCursor, direction: ${direction}`);
};
inputMethodController.off('moveCursor', onMoveCursorCallback);
inputMethodController.off('moveCursor'); inputMethodController.off('moveCursor');
``` ```
...@@ -2013,7 +2046,7 @@ try { ...@@ -2013,7 +2046,7 @@ try {
### off('handleExtendAction')<sup>10+</sup> ### off('handleExtendAction')<sup>10+</sup>
off(type: 'handleExtendAction'): void off(type: 'handleExtendAction', callback?: (action: ExtendAction) => void): void
Disables listening for the extended action handling event of the input method. Disables listening for the extended action handling event of the input method.
...@@ -2024,10 +2057,15 @@ Disables listening for the extended action handling event of the input method. ...@@ -2024,10 +2057,15 @@ Disables listening for the extended action handling event of the input method.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| type | string | Yes | Listening type.<br>The value **'handleExtendAction'** indicates the extended action handling event.| | type | string | Yes | Listening type.<br>The value **'handleExtendAction'** indicates the extended action handling event.|
| callback | (action: [ExtendAction](#extendaction10)) => void | No| Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example** **Example**
```js ```js
let onHandleExtendActionCallback = (action: ExtendAction) => {
console.log(`Succeeded in subscribing handleExtendAction, action: ${action}`);
};
inputMethodController.off('handleExtendAction', onHandleExtendActionCallback);
inputMethodController.off('handleExtendAction'); inputMethodController.off('handleExtendAction');
``` ```
...@@ -2056,7 +2094,7 @@ inputMethodController.on('selectByRange', (range) => { ...@@ -2056,7 +2094,7 @@ inputMethodController.on('selectByRange', (range) => {
### off('selectByRange')<sup>10+</sup> ### off('selectByRange')<sup>10+</sup>
off(type: 'selectByRange'): void off(type: 'selectByRange', callback?: Callback&lt;Range&gt;): void
Disables listening for the select-by-range event. Disables listening for the select-by-range event.
...@@ -2064,13 +2102,18 @@ Disables listening for the select-by-range event. ...@@ -2064,13 +2102,18 @@ Disables listening for the select-by-range event.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | -------- | --------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'selectByRange'** indicates the select-by-range event.| | type | string | Yes | Listening type.<br>The value **'selectByRange'** indicates the select-by-range event.|
| callback | Callback&lt;[Range](#range10)&gt; | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example** **Example**
```js ```js
let onSelectByRangeCallback = (range: Range) => {
console.log(`Succeeded in subscribing selectByRange, range: ${JSON.stringify(range)}`);
};
inputMethodController.off('selectByRange', onSelectByRangeCallback);
inputMethodController.off('selectByRange'); inputMethodController.off('selectByRange');
``` ```
...@@ -2099,7 +2142,7 @@ inputMethodController.on('selectByMovement', (movement) => { ...@@ -2099,7 +2142,7 @@ inputMethodController.on('selectByMovement', (movement) => {
### off('selectByMovement')<sup>10+</sup> ### off('selectByMovement')<sup>10+</sup>
off(type: 'selectByMovement'): void off(type: 'selectByMovement', callback?: Callback&lt;Movement&gt;): void
Disables listening for the select-by-cursor-movement event. Disables listening for the select-by-cursor-movement event.
...@@ -2107,13 +2150,18 @@ Disables listening for the select-by-cursor-movement event. ...@@ -2107,13 +2150,18 @@ Disables listening for the select-by-cursor-movement event.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'selectByMovement'** indicates the select-by-cursor-movement event.| | type | string | Yes | Listening type.<br>The value **'selectByMovement'** indicates the select-by-cursor-movement event.|
| callback | Callback&lt;[Movement](#movement10)> | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example** **Example**
```js ```js
let onSelectByMovementCallback = (movement: Movement) => {
console.log(`Succeeded in subscribing selectByMovement, movement.direction: ${movement.direction}`);
};
inputMethodController.off('selectByMovement', onSelectByMovementCallback);
inputMethodController.off('selectByMovement'); inputMethodController.off('selectByMovement');
``` ```
...@@ -2132,6 +2180,14 @@ Enables listening for the event of obtaining the length of text deleted backward ...@@ -2132,6 +2180,14 @@ Enables listening for the event of obtaining the length of text deleted backward
| type | string | Yes | Listening type.<br>The value **'getLeftTextOfCursor'** indicates the event of obtaining the length of text deleted backward.| | type | string | Yes | Listening type.<br>The value **'getLeftTextOfCursor'** indicates the event of obtaining the length of text deleted backward.|
| callback | (length: number) => string | Yes | Callback used to obtain the text of the specified length deleted backward.<br>In this callback, obtain the text of the specified length on the left of the cursor in the latest state of the edit box and return the text.| | callback | (length: number) => string | Yes | Callback used to obtain the text of the specified length deleted backward.<br>In this callback, obtain the text of the specified length on the left of the cursor in the latest state of the edit box and return the text.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| Error Code ID| Error Message |
| -------- | -------------------------------------- |
| 12800009 | input method client is detached. |
**Example** **Example**
```js ```js
...@@ -2150,7 +2206,7 @@ try { ...@@ -2150,7 +2206,7 @@ try {
off(type: 'getLeftTextOfCursor', callback?: (length: number) => string): void; off(type: 'getLeftTextOfCursor', callback?: (length: number) => string): void;
Disables listening for the event of obtaining the length of text deleted backward. This API uses an asynchronous callback to return the result. Disables listening for the event of obtaining the length of text deleted backward.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
...@@ -2190,6 +2246,14 @@ Enables listening for the event of obtaining the length of text deleted forward. ...@@ -2190,6 +2246,14 @@ Enables listening for the event of obtaining the length of text deleted forward.
| type | string | Yes | Listening type.<br>The value **'getRightTextOfCursor'** indicates the event of obtaining the length of text deleted forward.| | type | string | Yes | Listening type.<br>The value **'getRightTextOfCursor'** indicates the event of obtaining the length of text deleted forward.|
| callback | (length: number) => string | Yes | Callback used to obtain the text of the specified length deleted forward.<br>In this callback, obtain the text of the specified length on the right of the cursor in the latest state of the edit box and return the text.| | callback | (length: number) => string | Yes | Callback used to obtain the text of the specified length deleted forward.<br>In this callback, obtain the text of the specified length on the right of the cursor in the latest state of the edit box and return the text.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| Error Code ID| Error Message |
| -------- | -------------------------------------- |
| 12800009 | input method client is detached. |
**Example** **Example**
```js ```js
...@@ -2208,7 +2272,7 @@ try { ...@@ -2208,7 +2272,7 @@ try {
off(type: 'getRightTextOfCursor', callback?: (length: number) => string): void; off(type: 'getRightTextOfCursor', callback?: (length: number) => string): void;
Disables listening for the event of obtaining the length of text deleted forward. This API uses an asynchronous callback to return the result. Disables listening for the event of obtaining the length of text deleted forward.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
...@@ -2248,6 +2312,14 @@ Enables listening for the event of obtaining the index of text at the cursor. Th ...@@ -2248,6 +2312,14 @@ Enables listening for the event of obtaining the index of text at the cursor. Th
| type | string | Yes | Listening type.<br>The value **'getTextIndexAtCursor'** indicates the event of obtaining the index of text at the cursor.| | type | string | Yes | Listening type.<br>The value **'getTextIndexAtCursor'** indicates the event of obtaining the index of text at the cursor.|
| callback | () => number | Yes | Callback used to obtain the index of text at the cursor.<br>In this callback, obtain the index of text at the cursor in the latest state of the edit box and return the index.| | callback | () => number | Yes | Callback used to obtain the index of text at the cursor.<br>In this callback, obtain the index of text at the cursor in the latest state of the edit box and return the index.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| Error Code ID| Error Message |
| -------- | -------------------------------------- |
| 12800009 | input method client is detached. |
**Example** **Example**
```js ```js
...@@ -2266,7 +2338,7 @@ try { ...@@ -2266,7 +2338,7 @@ try {
off(type: 'getTextIndexAtCursor', callback?: () => number): void; off(type: 'getTextIndexAtCursor', callback?: () => number): void;
Disables listening for the event of obtaining the index of text at the cursor. This API uses an asynchronous callback to return the result. Disables listening for the event of obtaining the index of text at the cursor.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
......
...@@ -923,6 +923,50 @@ inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => { ...@@ -923,6 +923,50 @@ inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => {
}); });
``` ```
### on('editorAttributeChanged')<sup>10+</sup>
on(type: 'editorAttributeChanged', callback: (attr: EditorAttribute) => void): void
Enables listening for the edit box attribute change event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'editorAttributeChanged'** indicates the edit box attribute change event.|
| callback | (attr: EditorAttribute) => void | Yes | Callback used to return the edit box attribute change.|
**Example**
```js
inputMethodEngine.getKeyboardDelegate().on('editorAttributeChanged', (attr) => {
console.log(`Succeeded in receiving attribute of editor, inputPattern = ${attr.inputPattern}, enterKeyType = ${attr.enterKeyType}`);
});
```
### off('editorAttributeChanged')<sup>10+</sup>
off(type: 'editorAttributeChanged', callback?: (attr: EditorAttribute) => void): void
Cancels listening for the edit box attribute change event.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'editorAttributeChanged'** indicates the edit box attribute change event.|
| callback | (attr: EditorAttribute) => void | No | Callback for the edit box attribute change event. It must correspond to the one in the **on** API.|
**Example**
```js
inputMethodEngine.getKeyboardDelegate().off('editorAttributeChanged');
```
## Panel<sup>10+</sup> ## Panel<sup>10+</sup>
In the following API examples, you must first use **[createPanel](#createpanel10)** to obtain a **Panel** instance, and then call the APIs using the obtained instance. In the following API examples, you must first use **[createPanel](#createpanel10)** to obtain a **Panel** instance, and then call the APIs using the obtained instance.
......
...@@ -208,7 +208,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -208,7 +208,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17100010 | Can not post message using this port. | | 17100010 | Can not post message using this port. |
### onMessageEventExt<sup>10+</sup> ### onMessageEventExt<sup>10+</sup>
onMessageEventExt(callback: (result: WebMessageExt) => void): void onMessageEventExt(callback: (result: WebMessageExt) => void): void
...@@ -358,7 +357,7 @@ window.addEventListener('message', function(event) { ...@@ -358,7 +357,7 @@ window.addEventListener('message', function(event) {
h5Port = event.ports[0]; // 1. Save the port number sent from the eTS side. h5Port = event.ports[0]; // 1. Save the port number sent from the eTS side.
h5Port.onmessage = function(event) { h5Port.onmessage = function(event) {
console.log("hwd In html got message"); console.log("hwd In html got message");
// 2. Receive the message sent from the ArkTS side. // 2. Receive the message sent from the eTS side.
var result = event.data; var result = event.data;
console.log("In html got message, typeof: ", typeof(result)); console.log("In html got message, typeof: ", typeof(result));
console.log("In html got message, result: ", (result)); console.log("In html got message, result: ", (result));
...@@ -401,7 +400,7 @@ window.addEventListener('message', function(event) { ...@@ -401,7 +400,7 @@ window.addEventListener('message', function(event) {
} }
}) })
// Use h5Port to send a message of the string type to the ArkTS side. // Use h5Port to send a message of the string type to the ets side.
function postStringToApp() { function postStringToApp() {
if (h5Port) { if (h5Port) {
console.log("In html send string message"); console.log("In html send string message");
...@@ -638,7 +637,7 @@ struct WebComponent { ...@@ -638,7 +637,7 @@ struct WebComponent {
Button('loadUrl') Button('loadUrl')
.onClick(() => { .onClick(() => {
try { try {
// The headers parameter is carried. // The headers parameter is passed.
this.controller.loadUrl('www.example.com', [{headerKey: "headerKey", headerValue: "headerValue"}]); this.controller.loadUrl('www.example.com', [{headerKey: "headerKey", headerValue: "headerValue"}]);
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
...@@ -999,7 +998,7 @@ struct WebComponent { ...@@ -999,7 +998,7 @@ struct WebComponent {
onActive(): void onActive(): void
Invoked to instruct the **\<Web>** component to enter the foreground, active state. Invoked to instruct the **\<Web>** component to enter the active foreground state.
**System capability**: SystemCapability.Web.Webview.Core **System capability**: SystemCapability.Web.Webview.Core
...@@ -1348,12 +1347,14 @@ HTML file to be loaded: ...@@ -1348,12 +1347,14 @@ HTML file to be loaded:
<html> <html>
<meta charset="utf-8"> <meta charset="utf-8">
<body> <body>
Hello world! <button type="button" onclick="htmlTest()">Click Me!</button>
<p id="demo"></p>
</body> </body>
<script type="text/javascript"> <script type="text/javascript">
function htmlTest() { function htmlTest() {
str = objName.test("test function") let str=objName.test();
console.log('objName.test result:'+ str) document.getElementById("demo").innerHTML=str;
console.log('objName.test result:'+ str)
} }
</script> </script>
</html> </html>
...@@ -3866,7 +3867,7 @@ struct WebComponent { ...@@ -3866,7 +3867,7 @@ struct WebComponent {
getCertificate(): Promise<Array<cert.X509Cert>> getCertificate(): Promise<Array<cert.X509Cert>>
Obtains the certificate information of the current website. When the \<Web> component is used to load an HTTPS website, SSL certificate verification is performed. This API uses a promise to return the [X.509 certificate](./js-apis-cert.md) of the current website. Obtains the certificate information of this website. When the **\<Web>** component is used to load an HTTPS website, SSL certificate verification is performed. This API uses a promise to return the [X.509 certificate](./js-apis-cert.md) of the current website.
**System capability**: SystemCapability.Web.Webview.Core **System capability**: SystemCapability.Web.Webview.Core
...@@ -3943,7 +3944,7 @@ struct Index { ...@@ -3943,7 +3944,7 @@ struct Index {
} }
.type(ButtonType.Capsule) .type(ButtonType.Capsule)
.onClick(() => { .onClick(() => {
//Load an HTTPS website and view the certificate information of the website. // Load an HTTPS website and view the certificate information of the website.
this.webviewCtl.loadUrl('https://www.example.com') this.webviewCtl.loadUrl('https://www.example.com')
}) })
.height(50) .height(50)
...@@ -4023,7 +4024,7 @@ struct Index { ...@@ -4023,7 +4024,7 @@ struct Index {
getCertificate(callback: AsyncCallback<Array<cert.X509Cert>>): void getCertificate(callback: AsyncCallback<Array<cert.X509Cert>>): void
Obtains the certificate information of the current website. When the \<Web> component is used to load an HTTPS website, SSL certificate verification is performed. This API uses an asynchronous callback to return the [X.509 certificate](./js-apis-cert.md) of the current website. Obtains the certificate information of this website. When the **\<Web>** component is used to load an HTTPS website, SSL certificate verification is performed. This API uses an asynchronous callback to return the [X.509 certificate](./js-apis-cert.md) of the website.
**System capability**: SystemCapability.Web.Webview.Core **System capability**: SystemCapability.Web.Webview.Core
...@@ -4031,7 +4032,7 @@ Obtains the certificate information of the current website. When the \<Web> comp ...@@ -4031,7 +4032,7 @@ Obtains the certificate information of the current website. When the \<Web> comp
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback<Array<cert.X509Cert>> | Yes | Callback used to obtain the X.509 certificate array of the current HTTPS website.| | callback | AsyncCallback<Array<cert.X509Cert>> | Yes | Callback used to obtain the X.509 certificate array of the current website.|
**Error codes** **Error codes**
...@@ -4100,7 +4101,7 @@ struct Index { ...@@ -4100,7 +4101,7 @@ struct Index {
} }
.type(ButtonType.Capsule) .type(ButtonType.Capsule)
.onClick(() => { .onClick(() => {
//Load an HTTPS website and view the certificate information of the website. // Load an HTTPS website and view the certificate information of the website.
this.webviewCtl.loadUrl('https://www.example.com') this.webviewCtl.loadUrl('https://www.example.com')
}) })
.height(50) .height(50)
...@@ -4222,10 +4223,111 @@ struct WebComponent { ...@@ -4222,10 +4223,111 @@ struct WebComponent {
} }
``` ```
### prefetchPage<sup>10+</sup>
prefetchPage(url: string, additionalHeaders?: Array\<WebHeader>): void
Prefetches resources in the background for a page that is likely to be accessed in the near future, without executing the page JavaScript code or presenting the page. This can significantly reduce the load time for the prefetched page.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ------------------| --------------------------------| ---- | ------------- |
| url | string | Yes | URL to be preloaded.|
| additionalHeaders | Array\<[WebHeader](#webheader)> | No | Additional HTTP headers of the URL.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID | Error Message |
| -------- | ------------------------------------------------------------ |
| 17100001 | Init error. The WebviewController must be associated with a Web component. |
| 17100002 | Invalid url. |
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('prefetchPopularPage')
.onClick(() => {
try {
// Replace 'https://www.example.com' with a real URL for the API to work.
this.controller.prefetchPage('https://www.example.com');
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
// Replace ''www.example1.com' with a real URL for the API to work.
Web({ src: 'www.example1.com', controller: this.controller })
}
}
}
```
### prepareForPageLoad<sup>10+</sup>
static prepareForPageLoad(url: string, preconnectable: boolean, numSockets: number): void
Preconnects to a URL. This API can be called before the URL is loaded, to resolve the DNS and establish a socket connection, without obtaining the resources.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ---------------| ------- | ---- | ------------- |
| url | string | Yes | URL to be preconnected.|
| preconnectable | boolean | Yes | Whether to perform preconnection, which involves DNS resolution and socket connection establishment. The value **true** means to perform preconnection, and **false** means the opposite.|
| numSockets | number | Yes | Number of sockets to be preconnected. The value must be greater than 0. A maximum of six socket connections are allowed.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID | Error Message |
| -------- | ------------------------------------------------------------ |
| 17100002 | Invalid url. |
| 171000013| The number of preconnect sockets is invalid. |
**Example**
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
console.log("EntryAbility onCreate")
web_webview.WebviewController.initializeWebEngine()
// Replace 'https://www.example.com' with a real URL for the API to work.
web_webview.WebviewController.prepareForPageLoad("https://www.example.com", true, 2);
globalThis.abilityWant = want
console.log("EntryAbility onCreate done")
}
}
```
## WebCookieManager ## WebCookieManager
Implements a **WebCookieManager** instance to manage behavior of cookies in **\<Web>** components. All **\<Web>** components in an application share a **WebCookieManager** instance. Implements a **WebCookieManager** instance to manage behavior of cookies in **\<Web>** components. All **\<Web>** components in an application share a **WebCookieManager** instance.
> **NOTE**
>
> You must load the **\<Web>** component before calling APIs in **WebCookieManager**.
### getCookie ### getCookie
static getCookie(url: string): string static getCookie(url: string): string
...@@ -4347,7 +4449,6 @@ Saves the cookies in the memory to the drive. This API uses an asynchronous call ...@@ -4347,7 +4449,6 @@ Saves the cookies in the memory to the drive. This API uses an asynchronous call
| -------- | ---------------------- | ---- | :------------------------------------------------- | | -------- | ---------------------- | ---- | :------------------------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return whether the cookies are successfully saved.| | callback | AsyncCallback\<void> | Yes | Callback used to return whether the cookies are successfully saved.|
**Example** **Example**
```ts ```ts
...@@ -4688,6 +4789,10 @@ struct WebComponent { ...@@ -4688,6 +4789,10 @@ struct WebComponent {
Implements a **WebStorage** object to manage the Web SQL database and HTML5 Web Storage APIs. All **\<Web>** components in an application share a **WebStorage** object. Implements a **WebStorage** object to manage the Web SQL database and HTML5 Web Storage APIs. All **\<Web>** components in an application share a **WebStorage** object.
> **NOTE**
>
> You must load the **\<Web>** component before calling the APIs in **WebStorage**.
### deleteOrigin ### deleteOrigin
static deleteOrigin(origin : string): void static deleteOrigin(origin : string): void
...@@ -5148,6 +5253,10 @@ struct WebComponent { ...@@ -5148,6 +5253,10 @@ struct WebComponent {
Implements a **WebDataBase** object. Implements a **WebDataBase** object.
> **NOTE**
>
> You must load the **\<Web>** component before calling the APIs in **WebDataBase**.
### getHttpAuthCredentials ### getHttpAuthCredentials
static getHttpAuthCredentials(host: string, realm: string): Array\<string> static getHttpAuthCredentials(host: string, realm: string): Array\<string>
...@@ -5326,6 +5435,10 @@ struct WebComponent { ...@@ -5326,6 +5435,10 @@ struct WebComponent {
Implements a **GeolocationPermissions** object. Implements a **GeolocationPermissions** object.
> **NOTE**
>
> You must load the **\<Web>** component before calling the APIs in **GeolocationPermissions**.
### Required Permissions ### Required Permissions
**ohos.permission.LOCATION**, **ohos.permission.APPROXIMATELY_LOCATION**, and **ohos.permission.LOCATION_IN_BACKGROUND**, which are required for accessing the location information. For details about the permissions, see [@ohos.geolocation (Geolocation)](./js-apis-geolocation.md). **ohos.permission.LOCATION**, **ohos.permission.APPROXIMATELY_LOCATION**, and **ohos.permission.LOCATION_IN_BACKGROUND**, which are required for accessing the location information. For details about the permissions, see [@ohos.geolocation (Geolocation)](./js-apis-geolocation.md).
...@@ -5739,7 +5852,6 @@ Describes the type of the returned result of script execution using [runJavaScir ...@@ -5739,7 +5852,6 @@ Describes the type of the returned result of script execution using [runJavaScir
| ARRAY_BUFFER | 4 |Raw binary data buffer.| | ARRAY_BUFFER | 4 |Raw binary data buffer.|
| ARRAY | 5 |Array type.| | ARRAY | 5 |Array type.|
## WebMessageType<sup>10+</sup> ## WebMessageType<sup>10+</sup>
Describes the data type supported by the [webMessagePort](#webmessageport) API. Describes the data type supported by the [webMessagePort](#webmessageport) API.
...@@ -5796,7 +5908,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -5796,7 +5908,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. | | 17100014 | The type does not match with the value of the result. |
### getNumber<sup>10+</sup> ### getNumber<sup>10+</sup>
getNumber(): number getNumber(): number
...@@ -5841,7 +5952,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -5841,7 +5952,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. | | 17100014 | The type does not match with the value of the result. |
### getArrayBuffer<sup>10+</sup> ### getArrayBuffer<sup>10+</sup>
getArrayBuffer(): ArrayBuffer getArrayBuffer(): ArrayBuffer
...@@ -5885,7 +5995,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -5885,7 +5995,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. | | 17100014 | The type does not match with the value of the result. |
## WebMessageExt<sup>10+</sup> ## WebMessageExt<sup>10+</sup>
Data object received and sent by the [webMessagePort](#webmessageport) interface. Data object received and sent by the [webMessagePort](#webmessageport) interface.
...@@ -5904,7 +6013,6 @@ Obtains the type of the data object. ...@@ -5904,7 +6013,6 @@ Obtains the type of the data object.
| --------------| --------------------------------------------------------- | | --------------| --------------------------------------------------------- |
| [WebMessageType](#webmessagetype10) | Data type supported by the [webMessagePort](#webmessageport) API.| | [WebMessageType](#webmessagetype10) | Data type supported by the [webMessagePort](#webmessageport) API.|
### getString<sup>10+</sup> ### getString<sup>10+</sup>
getString(): string getString(): string
...@@ -5927,7 +6035,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -5927,7 +6035,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. | | 17100014 | The type does not match with the value of the web message. |
### getNumber<sup>10+</sup> ### getNumber<sup>10+</sup>
getNumber(): number getNumber(): number
...@@ -5950,7 +6057,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -5950,7 +6057,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. | | 17100014 | The type does not match with the value of the web message. |
### getBoolean<sup>10+</sup> ### getBoolean<sup>10+</sup>
getBoolean(): boolean getBoolean(): boolean
...@@ -5973,7 +6079,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -5973,7 +6079,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. | | 17100014 | The type does not match with the value of the web message. |
### getArrayBuffer<sup>10+</sup> ### getArrayBuffer<sup>10+</sup>
getArrayBuffer(): ArrayBuffer getArrayBuffer(): ArrayBuffer
...@@ -6039,7 +6144,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error ...@@ -6039,7 +6144,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. | | 17100014 | The type does not match with the value of the web message. |
### setType<sup>10+</sup> ### setType<sup>10+</sup>
setType(type: WebMessageType): void setType(type: WebMessageType): void
...@@ -6180,7 +6284,6 @@ Sets the error-object-type data for the data object. For the complete sample cod ...@@ -6180,7 +6284,6 @@ Sets the error-object-type data for the data object. For the complete sample cod
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. | | 17100014 | The type does not match with the value of the web message. |
## WebStorageOrigin ## WebStorageOrigin
Provides usage information of the Web SQL Database. Provides usage information of the Web SQL Database.
......
...@@ -39,9 +39,9 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -39,9 +39,9 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
In addition to the [universal events](ts-universal-events-click.md), the following attributes are supported. In addition to the [universal events](ts-universal-events-click.md), the following attributes are supported.
| Name | Description | | Name | Description |
| -------------------------------------------- | ------------------------------------------------------------ | | -------------------------------------------- | ------------------------------------------------------------ |
| onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes.<br>- The value **true** means that the check box is selected.<br>- The value **false** means that the check box is not selected.<br>Since API version 9, this API is supported in ArkTS widgets. | | onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes.<br>- The value **true** means that the check box is selected.<br>- The value **false** means that the check box is not selected.<br>Since API version 9, this API is supported in ArkTS widgets.|
## MarkStyle<sup>10+</sup> ## MarkStyle<sup>10+</sup>
...@@ -53,6 +53,8 @@ In addition to the [universal events](ts-universal-events-click.md), the followi ...@@ -53,6 +53,8 @@ In addition to the [universal events](ts-universal-events-click.md), the followi
## Example ## Example
### Example 1
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
...@@ -80,3 +82,51 @@ struct CheckboxExample { ...@@ -80,3 +82,51 @@ struct CheckboxExample {
![](figures/checkbox.gif) ![](figures/checkbox.gif)
### Example 2
```ts
// xxx.ets
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox1 change is'+ value)
})
.mark({
strokeColor:Color.Black,
size: 50,
strokeWidth: 5
})
.unselectedColor(Color.Red)
.width(30)
.height(30)
Text('Checkbox1').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox2', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is' + value)
})
.width(30)
.height(30)
Text('Checkbox2').fontSize(20)
}
}
.width('100%')
}
.height('100%')
}
}
```
![](figures/checkbox2.gif)
...@@ -72,6 +72,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -72,6 +72,8 @@ Since API version 9, this API is supported in ArkTS widgets.
## Example ## Example
### Example 1
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
...@@ -124,4 +126,77 @@ struct CheckboxExample { ...@@ -124,4 +126,77 @@ struct CheckboxExample {
} }
} }
``` ```
![checkboxgroup](figures/checkboxgroup.gif) ![checkboxGroup](figures/checkboxGroup.gif)
### Example 2
```ts
// xxx.ets
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
CheckboxGroup({ group: 'checkboxGroup' })
.selectedColor(Color.Orange)
.onChange((itemName: CheckboxGroupResult) => {
console.info("checkbox group content" + JSON.stringify(itemName))
})
.mark({
strokeColor:Color.Black,
size: 40,
strokeWidth: 5
})
.unselectedColor(Color.Red)
.width(30)
.height(30)
Text('Select All').fontSize(20)
}.margin({right:15})
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox1 change is'+ value)
})
.mark({
strokeColor:Color.Black,
size: 50,
strokeWidth: 5
})
.unselectedColor(Color.Red)
.width(30)
.height(30)
Text('Checkbox1').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox2', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is' + value)
})
.width(30)
.height(30)
Text('Checkbox2').fontSize(20)
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Checkbox({ name: 'checkbox3', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox3 change is' + value)
})
.width(30)
.height(30)
Text('Checkbox3').fontSize(20)
}
}
.width('100%')
}
.height('100%')
}
}
```
![checkboxGroup](figures/checkboxGroup2.gif)
...@@ -43,14 +43,14 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -43,14 +43,14 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| hideToolBar | boolean | Whether to hide the toolbar.<br>Default value: **false**<br>**true**: Hide the toolbar.<br>**false**: Display the toolbar.| | hideToolBar | boolean | Whether to hide the toolbar.<br>Default value: **false**<br>**true**: Hide the toolbar.<br>**false**: Display the toolbar.|
| hideTitleBar | boolean | Whether to hide the title bar.<br>Default value: **false**<br>**true**: Hide the title bar.<br>**false**: Display the title bar.| | hideTitleBar | boolean | Whether to hide the title bar.<br>Default value: **false**<br>**true**: Hide the title bar.<br>**false**: Display the title bar.|
| hideBackButton | boolean | Whether to hide the back button.<br>Default value: **false**<br>**true**: Hide the back button.<br>**false**: Display the back button.<br>The back button in the title bar of the **\<NavDestination>** component cannot be hidden.<br>**NOTE**<br>The back button works only when **titleMode** is set to **NavigationTitleMode.Mini**.| | hideBackButton | boolean | Whether to hide the back button.<br>Default value: **false**<br>**true**: Hide the back button.<br>**false**: Display the back button.<br>The back button in the title bar of the **\<NavDestination>** component cannot be hidden.<br>**NOTE**<br>The back button works only when **titleMode** is set to **NavigationTitleMode.Mini**.|
| navBarWidth<sup>9+</sup> | [Length](ts-types.md#length) | Width of the navigation bar.<br>Default value: **200**<br>Unit: vp<br>**NOTE**<br>This attribute is valid only when the **\<Navigation>** component is split.| | navBarWidth<sup>9+</sup> | [Length](ts-types.md#length) | Width of the navigation bar.<br>Default value: **240**<br>Unit: vp<br>**NOTE**<br>This attribute is valid only when the **\<Navigation>** component is split.|
| navBarPosition<sup>9+</sup> | [NavBarPosition](#navbarposition) | Position of the navigation bar.<br>Default value: **NavBarPosition.Start**<br>**NOTE**<br>This attribute is valid only when the **\<Navigation>** component is split.| | navBarPosition<sup>9+</sup> | [NavBarPosition](#navbarposition) | Position of the navigation bar.<br>Default value: **NavBarPosition.Start**<br>**NOTE**<br>This attribute is valid only when the **\<Navigation>** component is split.|
| mode<sup>9+</sup> | [NavigationMode](#navigationmode) | Display mode of the navigation bar.<br>Default value: **NavigationMode.Auto**<br>At the default settings, the component adapts to a single column or two columns based on the component width.| | mode<sup>9+</sup> | [NavigationMode](#navigationmode) | Display mode of the navigation bar.<br>Default value: **NavigationMode.Auto**<br>At the default settings, the component adapts to a single column or two columns based on the component width.<br>**NOTE**<br>Available options are **Stack**, **Split**, and **Auto**.|
| backButtonIcon<sup>9+</sup> | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | Back button icon on the navigation bar. The back button in the title bar of the **\<NavDestination>** component cannot be hidden.| | backButtonIcon<sup>9+</sup> | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | Back button icon on the navigation bar. The back button in the title bar of the **\<NavDestination>** component cannot be hidden.|
| hideNavBar<sup>9+</sup> | boolean | Whether to hide the navigation bar. This attribute is valid only when **mode** is set to **NavigationMode.Split**.| | hideNavBar<sup>9+</sup> | boolean | Whether to hide the navigation bar. This attribute is valid only when **mode** is set to **NavigationMode.Split**.|
| navDestination<sup>10+</sup> | builder: (name: string, param: unknown) => void | Creates a **\<NavDestination>** component.<br>**NOTE**<br>The **builder** function is used, with the **name** and **param** parameters passed in. In the builder, a layer of custom components can be included outside the **\<NavDestination>** component. However, no attributes or events can be set for the custom components. Otherwise, only blank components are displayed.| | navDestination<sup>10+</sup> | builder: (name: string, param: unknown) => void | Creates a **\<NavDestination>** component.<br>**NOTE**<br>The **builder** function is used, with the **name** and **param** parameters passed in. In the builder, a layer of custom components can be included outside the **\<NavDestination>** component. However, no attributes or events can be set for the custom components. Otherwise, only blank components are displayed.|
| navBarWidthRange<sup>10+</sup> | [[Dimension](ts-types.md#dimension10), [Dimension](ts-types.md#dimension10)] | Minimum and maximum widths of the navigation bar.<br>Default value: **240** for the minimum value; 40% of the component width (not greater than 432) for the maximum value<br>Unit: vp<br>Priority rules:<br>Custom value > Default value<br>Minimum value > Maximum value<br>navBar > content<br>If values conflict, the global value takes precedence, and the local minimum value depends on the container size.| | navBarWidthRange<sup>10+</sup> | [[Dimension](ts-types.md#dimension10), [Dimension](ts-types.md#dimension10)] | Minimum and maximum widths of the navigation bar (valid in dual-column mode).<br>Default value: **240** for the minimum value; 40% of the component width (not greater than 432) for the maximum value<br>Unit: vp<br>Priority rules:<br>Custom value > Default value<br>Minimum value > Maximum value<br>navBar > content<br>If values conflict, the global value takes precedence, and the local minimum value depends on the container size.|
| minContentWidth<sup>10+</sup> | [Dimension](ts-types.md#dimension10) | Minimum width of the navigation bar content area.<br>Default value: **360**<br>Unit: vp<br>Priority rules:<br>Custom value > Default value<br>Minimum value > Maximum value<br>navBar > content<br>If values conflict, the global value takes precedence, and the local minimum value depends on the container size.<br>Breakpoint calculation in Auto mode: default 600vp = minNavBarWidth (240vp) + minContentWidth (360vp)| | minContentWidth<sup>10+</sup> | [Dimension](ts-types.md#dimension10) | Minimum width of the navigation bar content area (valid in dual-column mode).<br>Default value: **360**<br>Unit: vp<br>Priority rules:<br>Custom value > Default value<br>Minimum value > Maximum value<br>navBar > content<br>If values conflict, the global value takes precedence, and the local minimum value depends on the container size.<br>Breakpoint calculation in Auto mode: default 600 vp = minNavBarWidth (240 vp) + minContentWidth (360 vp)|
## NavPathStack<sup>10+</sup> ## NavPathStack<sup>10+</sup>
...@@ -319,11 +319,11 @@ constructor(name: string, param: unknown) ...@@ -319,11 +319,11 @@ constructor(name: string, param: unknown)
## NavigationMode ## NavigationMode
| Name | Description | | Name | Description |
| ----- | ---------------------------------------- | | ----- | ------------------------------------------------------------ |
| Stack | The navigation bar and content area are displayed independently of each other, which are equivalent to two pages. | | Stack | The navigation bar and content area are displayed independently of each other, which are equivalent to two pages. |
| Split | The navigation bar and content area are displayed in different columns. | | Split | The navigation bar and content area are displayed in different columns. |
| Auto | When the window width is greater than or equal to 520 vp, Split mode is used. Otherwise, the Stack mode is used.| | Auto | In API version 9 and earlier versions: When the window width is greater than or equal to 520 vp, the Split mode is used. In other cases, the Stack mode is used.<br>In API version 10 and later versions: When the window width is greater than or equal to 600 vp, the Split mode is used. In other cases, the Stack mode is used. 600 vp = minNavBarWidth (240 vp) + minContentWidth (360 vp).|
## TitleHeight ## TitleHeight
......
...@@ -107,32 +107,31 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController}) ...@@ -107,32 +107,31 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController})
``` ```
2. Modify the **EntryAbility.ts** file. 2. Modify the **EntryAbility.ts** file.
The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths).
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// Bind filesDir to the globalThis object to implement data synchronization between the UIAbility component and the UI.
globalThis.filesDir = this.context.filesDir
console.log("Sandbox path is " + globalThis.filesDir)
}
}
```
The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths). HTML file to be loaded:
```ts ```html
// xxx.ts <!-- index.html -->
import UIAbility from '@ohos.app.ability.UIAbility'; <!DOCTYPE html>
import web_webview from '@ohos.web.webview'; <html>
<body>
export default class EntryAbility extends UIAbility { <p>Hello World</p>
onCreate(want, launchParam) { </body>
// Bind filesDir to the globalThis object to implement data synchronization between the UIAbility component and the UI. </html>
globalThis.filesDir = this.context.filesDir ```
console.log("Sandbox path is " + globalThis.filesDir)
}
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
```
## Attributes ## Attributes
...@@ -672,12 +671,16 @@ Sets whether to display the vertical scrollbar, including the default system scr ...@@ -672,12 +671,16 @@ Sets whether to display the vertical scrollbar, including the default system scr
</html> </html>
``` ```
### password ### password<sup>(deprecated)</sup>
password(password: boolean) password(password: boolean)
Sets whether the password should be saved. This API is a void API. Sets whether the password should be saved. This API is a void API.
> **NOTE**
>
> This API is deprecated since API version 10, and no new API is provided as a substitute.
### cacheMode ### cacheMode
cacheMode(cacheMode: CacheMode) cacheMode(cacheMode: CacheMode)
...@@ -993,7 +996,6 @@ Sets the minimum logical font size for the web page. ...@@ -993,7 +996,6 @@ Sets the minimum logical font size for the web page.
} }
``` ```
### webFixedFont<sup>9+</sup> ### webFixedFont<sup>9+</sup>
webFixedFont(family: string) webFixedFont(family: string)
...@@ -1244,18 +1246,26 @@ Sets whether to enable forcible dark mode for the web page. By default, this fea ...@@ -1244,18 +1246,26 @@ Sets whether to enable forcible dark mode for the web page. By default, this fea
} }
``` ```
### tableData ### tableData<sup>(deprecated)</sup>
tableData(tableData: boolean) tableData(tableData: boolean)
Sets whether form data should be saved. This API is a void API. Sets whether form data should be saved. This API is a void API.
### wideViewModeAccess > **NOTE**
>
> This API is deprecated since API version 10, and no new API is provided as a substitute.
### wideViewModeAccess<sup>(deprecated)</sup>
wideViewModeAccess(wideViewModeAccess: boolean) wideViewModeAccess(wideViewModeAccess: boolean)
Sets whether to support the viewport attribute of the HTML **\<meta>** tag. This API is a void API. Sets whether to support the viewport attribute of the HTML **\<meta>** tag. This API is a void API.
> **NOTE**
>
> This API is deprecated since API version 10, and no new API is provided as a substitute.
### pinchSmooth<sup>9+</sup> ### pinchSmooth<sup>9+</sup>
pinchSmooth(isEnabled: boolean) pinchSmooth(isEnabled: boolean)
...@@ -1386,7 +1396,6 @@ Sets the web-based media playback policy, including the validity period for auto ...@@ -1386,7 +1396,6 @@ Sets the web-based media playback policy, including the validity period for auto
**Example** **Example**
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview' import web_webview from '@ohos.web.webview'
...@@ -1941,7 +1950,6 @@ Called when an HTTP error (the response code is greater than or equal to 400) oc ...@@ -1941,7 +1950,6 @@ Called when an HTTP error (the response code is greater than or equal to 400) oc
onPageBegin(callback: (event?: { url: string }) => void) onPageBegin(callback: (event?: { url: string }) => void)
Called when the web page starts to be loaded. This API is called only for the main frame content, and not for the iframe or frameset content. Called when the web page starts to be loaded. This API is called only for the main frame content, and not for the iframe or frameset content.
**Parameters** **Parameters**
...@@ -1976,7 +1984,6 @@ Called when the web page starts to be loaded. This API is called only for the ma ...@@ -1976,7 +1984,6 @@ Called when the web page starts to be loaded. This API is called only for the ma
onPageEnd(callback: (event?: { url: string }) => void) onPageEnd(callback: (event?: { url: string }) => void)
Called when the web page loading is complete. This API takes effect only for the main frame content. Called when the web page loading is complete. This API takes effect only for the main frame content.
**Parameters** **Parameters**
...@@ -2979,7 +2986,7 @@ If opening a new window is not needed, set the parameter to **null** when callin ...@@ -2979,7 +2986,7 @@ If opening a new window is not needed, set the parameter to **null** when callin
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview' import web_webview from '@ohos.web.webview'
// There are two <Web> components on the same page. When the WebComponent object opens a new window, the NewWebViewComp object is displayed. // There are two <Web> components on the same page. When the WebComponent object opens a new window, the NewWebViewComp object is displayed.
@CustomDialog @CustomDialog
struct NewWebViewComp { struct NewWebViewComp {
...@@ -3335,8 +3342,8 @@ Called when the web page content is first rendered. ...@@ -3335,8 +3342,8 @@ Called when the web page content is first rendered.
Column() { Column() {
Web({ src:'www.example.com', controller: this.controller }) Web({ src:'www.example.com', controller: this.controller })
.onFirstContentfulPaint(event => { .onFirstContentfulPaint(event => {
console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" + console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" +
event.navigationStartTick + ", [firstContentfulPaintMs]:" + event.navigationStartTick + ", [firstContentfulPaintMs]:" +
event.firstContentfulPaintMs) event.firstContentfulPaintMs)
}) })
} }
...@@ -3415,7 +3422,156 @@ Called when the **\<Web>** component obtains the focus. ...@@ -3415,7 +3422,156 @@ Called when the **\<Web>** component obtains the focus.
} }
} }
``` ```
### onScreenCaptureRequest<sup>10+</sup>
onScreenCaptureRequest(callback: (event?: { handler: ScreenCaptureHandler }) => void)
Called when a screen capture request is received.
**Parameters**
| Name | Type | Description |
| ------- | ---------------------------------------- | -------------- |
| handler | [ScreenCaptureHandler](#screencapturehandler10) | User operation.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.onScreenCaptureRequest((event) => {
AlertDialog.show({
title: 'title: ' + event.handler.getOrigin(),
message: 'text',
primaryButton: {
value: 'deny',
action: () => {
event.handler.deny()
}
},
secondaryButton: {
value: 'onConfirm',
action: () => {
event.handler.grant({ captureMode: WebCaptureMode.HOME_SCREEN })
}
},
cancel: () => {
event.handler.deny()
}
})
})
}
}
}
```
### onOverScroll<sup>10+</sup>
onOverScroll(callback: (event: {xOffset: number, yOffset: number}) => void)
Called to indicate the offset by which the web page overscrolls.
**Parameters**
| Name | Type | Description |
| ------- | ------ | ------------ |
| xOffset | number | Horizontal overscroll offset based on the leftmost edge of the web page.|
| yOffset | number | Vertical overscroll offset based on the top edge of the web page.|
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.onOverScroll((event) => {
console.info("x = " + event.xOffset)
console.info("y = " + event.yOffset)
})
}
}
}
```
### onControllerAttached<sup>10+</sup>
onControllerAttached(callback: () => void)
Called when the controller is successfully bound to the **\<Web>** component. The controller must be WebviewController.
As the web page is not yet loaded when this callback is called, APIs for operating the web page cannot be used in the callback, for example, [zoomIn](../apis/js-apis-webview.md#zoomin) and [zoomOut]. (../apis/js-apis-webview.md#zoomout). Other APIs, such as [loadUrl] (../apis/js-apis-webview.md#loadurl) and [getWebId] (../apis/js-apis-webview.md#getwebid), which do not involve web page operations, can be used properly.
**Example**
The following example uses **loadUrl** in the callback to load the web page.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: '', controller: this.controller })
.onControllerAttached(() => {
this.controller.loadUrl($rawfile("index.html"));
})
}
}
}
```
The following example uses **getWebId** in the callback
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: $rawfile("index.html"), controller: this.controller })
.onControllerAttached(() => {
try {
let id = this.controller.getWebId();
console.log("id: " + id);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
}
}
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
```
## ConsoleMessage ## ConsoleMessage
Implements the **ConsoleMessage** object. For the sample code, see [onConsole](#onconsole). Implements the **ConsoleMessage** object. For the sample code, see [onConsole](#onconsole).
...@@ -3470,7 +3626,7 @@ Obtains the path and name of the web page source file. ...@@ -3470,7 +3626,7 @@ Obtains the path and name of the web page source file.
## JsResult ## JsResult
Implements the **JsResult** object, which indicates the result returned to the **\<Web>** component to indicate the user operation performed in the dialog box. For the sample code, see [onAlert](#onalert). Implements the **JsResult** object, which indicates the result returned to the **\<Web>** component to indicate the user operation performed in the dialog box. For the sample code, see [onAlert Event](#onalert).
### handleCancel ### handleCancel
...@@ -3635,7 +3791,6 @@ Describes the request/response header returned by the **\<Web>** component. ...@@ -3635,7 +3791,6 @@ Describes the request/response header returned by the **\<Web>** component.
| headerKey | string | Key of the request/response header. | | headerKey | string | Key of the request/response header. |
| headerValue | string | Value of the request/response header.| | headerValue | string | Value of the request/response header.|
## WebResourceResponse ## WebResourceResponse
Implements the **WebResourceResponse** object. For the sample code, see [onHttpErrorReceive](#onhttperrorreceive). Implements the **WebResourceResponse** object. For the sample code, see [onHttpErrorReceive](#onhttperrorreceive).
...@@ -4010,6 +4165,42 @@ Grants the permission for resources requested by the web page. ...@@ -4010,6 +4165,42 @@ Grants the permission for resources requested by the web page.
| --------- | --------------- | ---- | ---- | ------------- | | --------- | --------------- | ---- | ---- | ------------- |
| resources | Array\<string\> | Yes | - | List of resources that can be requested by the web page with the permission to grant.| | resources | Array\<string\> | Yes | - | List of resources that can be requested by the web page with the permission to grant.|
## ScreenCaptureHandler<sup>10+</sup>
Implements the **ScreenCaptureHandler** object for accepting or rejecting a screen capture request. For the sample code, see [onScreenCaptureRequest Event](#onscreencapturerequest10).
### deny<sup>10+</sup>
deny(): void
Rejects this screen capture request.
### getOrigin<sup>10+</sup>
getOrigin(): string
Obtains the origin of this web page.
**Return value**
| Type | Description |
| ------ | ------------ |
| string | Origin of the web page that requests the permission.|
### grant<sup>10+</sup>
grant(config: ScreenCaptureConfig): void
**Required permissions**: ohos.permission.MICROPHONE, ohos.permission.CAPTURE_SCREEN
Grants the screen capture permission.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| --------- | --------------- | ---- | ---- | ------------- |
| config | [ScreenCaptureConfig](#screencaptureconfig10) | Yes | - | Screen capture configuration.|
## ContextMenuSourceType<sup>9+</sup> ## ContextMenuSourceType<sup>9+</sup>
| Name | Description | | Name | Description |
| -------------------- | ---------- | | -------------------- | ---------- |
...@@ -4327,6 +4518,7 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API. ...@@ -4327,6 +4518,7 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API.
| --------- | ------------- | -------------------------- | | --------- | ------------- | -------------------------- |
| MidiSysex | MIDI SYSEX resource.| Currently, only permission events can be reported. MIDI devices are not yet supported.| | MidiSysex | MIDI SYSEX resource.| Currently, only permission events can be reported. MIDI devices are not yet supported.|
| VIDEO_CAPTURE<sup>10+</sup> | Video capture resource, such as a camera.| | | VIDEO_CAPTURE<sup>10+</sup> | Video capture resource, such as a camera.| |
| AUDIO_CAPTURE<sup>10+</sup> | Audio capture resource, such as a microphone.| |
## WebDarkMode<sup>9+</sup> ## WebDarkMode<sup>9+</sup>
| Name | Description | | Name | Description |
...@@ -4335,6 +4527,12 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API. ...@@ -4335,6 +4527,12 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API.
| On | The web dark mode is enabled. | | On | The web dark mode is enabled. |
| Auto | The web dark mode setting follows the system settings. | | Auto | The web dark mode setting follows the system settings. |
## WebCaptureMode<sup>10+</sup>
| Name | Description |
| --------- | ------------- |
| HOME_SCREEN | Capture of the home screen.|
## WebMediaOptions<sup>10+</sup> ## WebMediaOptions<sup>10+</sup>
Describes the web-based media playback policy. Describes the web-based media playback policy.
...@@ -4344,6 +4542,14 @@ Describes the web-based media playback policy. ...@@ -4344,6 +4542,14 @@ Describes the web-based media playback policy.
| resumeInterval | number | Yes | Yes | No |Validity period for automatically resuming a paused web audio, in seconds. The maximum validity period is 60 seconds. Due to the approximate value, the validity period may have a deviation of less than 1 second.| | resumeInterval | number | Yes | Yes | No |Validity period for automatically resuming a paused web audio, in seconds. The maximum validity period is 60 seconds. Due to the approximate value, the validity period may have a deviation of less than 1 second.|
| audioExclusive | boolean | Yes | Yes | No | Whether the audio of multiple **\<Web>** instances in an application is exclusive. | | audioExclusive | boolean | Yes | Yes | No | Whether the audio of multiple **\<Web>** instances in an application is exclusive. |
## ScreenCaptureConfig<sup>10+</sup>
Provides the web screen capture configuration.
| Name | Type | Readable| Writable| Mandatory| Description |
| -------------- | --------- | ---- | ---- | --- | ---------------------------- |
| captureMode | [WebCaptureMode](#webcapturemode10) | Yes | Yes | Yes | Web screen capture mode.|
## DataResubmissionHandler<sup>9+</sup> ## DataResubmissionHandler<sup>9+</sup>
Implements the **DataResubmissionHandler** object for resubmitting or canceling the web form data. Implements the **DataResubmissionHandler** object for resubmitting or canceling the web form data.
...@@ -4653,7 +4859,7 @@ This API is deprecated since API version 9. You are advised to use [forward<sup> ...@@ -4653,7 +4859,7 @@ This API is deprecated since API version 9. You are advised to use [forward<sup>
deleteJavaScriptRegister(name: string) deleteJavaScriptRegister(name: string)
Deletes a specific application JavaScript object that is registered with the window through **registerJavaScriptProxy**. The deletion takes effect immediately, with no need for invoking the[refresh](#refreshdeprecated) API. Deletes a specific application JavaScript object that is registered with the window through **registerJavaScriptProxy**. The deletion takes effect immediately, with no need for invoking the [refresh](#refreshdeprecated) API.
This API is deprecated since API version 9. You are advised to use [deleteJavaScriptRegister<sup>9+</sup>](../apis/js-apis-webview.md#deletejavascriptregister) instead. This API is deprecated since API version 9. You are advised to use [deleteJavaScriptRegister<sup>9+</sup>](../apis/js-apis-webview.md#deletejavascriptregister) instead.
......
...@@ -40,13 +40,13 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -40,13 +40,13 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Description | | Name | Type | Description |
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
| [fillStyle](#fillstyle) | string \|number<sup>10+</sup> \|[CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](ts-components-canvas-canvaspattern.md#canvaspattern) | Style to fill an area.<br>- When the type is string, this attribute indicates the color of the fill area.<br>- When the type is number, this attribute indicates the color of the fill area.<br>- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the **[createLinearGradient](#createlineargradient)** API.<br>- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the **[createPattern](#createpattern)** API.<br>Since API version 9, this API is supported in ArkTS widgets.| | [fillStyle](#fillstyle) | string \|number<sup>10+</sup> \|[CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](ts-components-canvas-canvaspattern.md#canvaspattern) | Style to fill an area.<br>- When the type is string, this attribute indicates the color of the fill area.<br>Default value: **'black'**<br>- When the type is number, this attribute indicates the color of the fill area.<br>Default value: **'#000000'**<br>- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the **[createLinearGradient](#createlineargradient)** API.<br>- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the **[createPattern](#createpattern)** API.<br>Since API version 9, this API is supported in ArkTS widgets.|
| [lineWidth](#linewidth) | number | Line width. | | [lineWidth](#linewidth) | number | Line width.<br>Default value: **1(px)** |
| [strokeStyle](#strokestyle) | string \|number<sup>10+</sup> \|[CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](ts-components-canvas-canvaspattern.md#canvaspattern) | Stroke style.<br>- When the type is string, this attribute indicates the stroke color.<br>- When the type is number, this attribute indicates the stroke color.<br>- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the **[createLinearGradient](#createlineargradient)** API.<br>- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the **[createPattern](#createpattern)** API.<br>Since API version 9, this API is supported in ArkTS widgets.| | [strokeStyle](#strokestyle) | string \|number<sup>10+</sup> \|[CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](ts-components-canvas-canvaspattern.md#canvaspattern) | Stroke style.<br>- When the type is string, this attribute indicates the stroke color.<br>Default value: **'black'**<br>- When the type is number, this attribute indicates the stroke color.<br>Default value: **'#000000'**<br>- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the **[createLinearGradient](#createlineargradient)** API.<br>- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the **[createPattern](#createpattern)** API.<br>Since API version 9, this API is supported in ArkTS widgets.|
| [lineCap](#linecap) | CanvasLineCap | Style of the line endpoints. The options are as follows:<br>- **'butt'**: The endpoints of the line are squared off.<br>- **'round'**: The endpoints of the line are rounded.<br>- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness.<br>Default value: **'butt'**<br>Since API version 9, this API is supported in ArkTS widgets.| | [lineCap](#linecap) | CanvasLineCap | Style of the line endpoints. The options are as follows:<br>- **'butt'**: The endpoints of the line are squared off.<br>- **'round'**: The endpoints of the line are rounded.<br>- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness.<br>Default value: **'butt'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| [lineJoin](#linejoin) | CanvasLineJoin | Style of the shape used to join line segments. The options are as follows:<br>- **'round'**: The shape used to join line segments is a sector, whose radius at the rounded corner is equal to the line width.<br>- **'bevel'**: The shape used to join line segments is a triangle. The rectangular corner of each line is independent.<br>- **'miter'**: The shape used to join line segments has a mitered corner by extending the outside edges of the lines until they meet. You can view the effect of this attribute in **miterLimit**.<br>Default value: **'miter'**<br>Since API version 9, this API is supported in ArkTS widgets.| | [lineJoin](#linejoin) | CanvasLineJoin | Style of the shape used to join line segments. The options are as follows:<br>- **'round'**: The shape used to join line segments is a sector, whose radius at the rounded corner is equal to the line width.<br>- **'bevel'**: The shape used to join line segments is a triangle. The rectangular corner of each line is independent.<br>- **'miter'**: The shape used to join line segments has a mitered corner by extending the outside edges of the lines until they meet. You can view the effect of this attribute in **miterLimit**.<br>Default value: **'miter'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| [miterLimit](#miterlimit) | number | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet.<br>Default value: **10**<br>Since API version 9, this API is supported in ArkTS widgets.| | [miterLimit](#miterlimit) | number | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet.<br>Default value: **10**<br>Since API version 9, this API is supported in ArkTS widgets.|
| [font](#font) | string | Font style.<br>Syntax: ctx.font='font-size font-family'<br>- (Optional) **font-size**: font size and row height. The unit can only be pixels.<br>- (Optional) **font-family**: font family.<br>Syntax: ctx.font='font-style font-weight font-size font-family'<br>- (Optional) **font-style**: font style. Available values are **'normal'** and **'italic'**.<br>- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **'100'**, **'200'**, **'300'**, **'400'**, **'500'**, **'600'**, **'700'**, **'800'**, **'900'**.<br>- (Optional) **font-size**: font size and row height. The unit must be specified and can only be px or vp.<br>- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**.<br>Default value: **'normal normal 14px sans-serif'**<br>Since API version 9, this API is supported in ArkTS widgets.| | [font](#font) | string | Font style.<br>Syntax: ctx.font='font-size font-family'<br>- (Optional) **font-size**: font size and row height. The unit can only be px.<br>- (Optional) **font-family**: font family.<br>Syntax: ctx.font='font-style font-weight font-size font-family'<br>- (Optional) **font-style**: font style. Available values are **'normal'** and **'italic'**.<br>- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **'100'**, **'200'**, **'300'**, **'400'**, **'500'**, **'600'**, **'700'**, **'800'**, **'900'**.<br>- (Optional) **font-size**: font size and row height. The unit must be specified and can only be px or vp.<br>- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**.<br>Default value: **'normal normal 14px sans-serif'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| [textAlign](#textalign) | CanvasTextAlign | Text alignment mode. Available values are as follows:<br>- **'left'**: The text is left-aligned.<br>- **'right'**: The text is right-aligned.<br>- **'center'**: The text is center-aligned.<br>- **'start'**: The text is aligned with the start bound.<br>- **'end'**: The text is aligned with the end bound.<br>In the **ltr** layout mode, the value **'start'** equals **'left'**. In the **rtl** layout mode, the value **'start'** equals **'right'**.<br>Default value: **'left'**<br>Since API version 9, this API is supported in ArkTS widgets.| | [textAlign](#textalign) | CanvasTextAlign | Text alignment mode. Available values are as follows:<br>- **'left'**: The text is left-aligned.<br>- **'right'**: The text is right-aligned.<br>- **'center'**: The text is center-aligned.<br>- **'start'**: The text is aligned with the start bound.<br>- **'end'**: The text is aligned with the end bound.<br>In the **ltr** layout mode, the value **'start'** equals **'left'**. In the **rtl** layout mode, the value **'start'** equals **'right'**.<br>Default value: **'left'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| [textBaseline](#textbaseline) | CanvasTextBaseline | Horizontal alignment mode of text. Available values are as follows:<br>- **'alphabetic'**: The text baseline is the normal alphabetic baseline.<br>- **'top'**: The text baseline is on the top of the text bounding box.<br>- **'hanging'**: The text baseline is a hanging baseline over the text.<br>- **'middle'**: The text baseline is in the middle of the text bounding box.<br>**'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.<br>- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line.<br>Default value: **'alphabetic'**<br>Since API version 9, this API is supported in ArkTS widgets.| | [textBaseline](#textbaseline) | CanvasTextBaseline | Horizontal alignment mode of text. Available values are as follows:<br>- **'alphabetic'**: The text baseline is the normal alphabetic baseline.<br>- **'top'**: The text baseline is on the top of the text bounding box.<br>- **'hanging'**: The text baseline is a hanging baseline over the text.<br>- **'middle'**: The text baseline is in the middle of the text bounding box.<br>**'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.<br>- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line.<br>Default value: **'alphabetic'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| [globalAlpha](#globalalpha) | number | Opacity.<br>**0.0**: completely transparent.<br>**1.0**: completely opaque.<br>Since API version 9, this API is supported in ArkTS widgets.| | [globalAlpha](#globalalpha) | number | Opacity.<br>**0.0**: completely transparent.<br>**1.0**: completely opaque.<br>Since API version 9, this API is supported in ArkTS widgets.|
...@@ -59,8 +59,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -59,8 +59,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite.<br>Default value: **true**<br>Since API version 9, this API is supported in ArkTS widgets.| | [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite.<br>Default value: **true**<br>Since API version 9, this API is supported in ArkTS widgets.|
| [height](#height) | number | Component height.<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.| | [height](#height) | number | Component height.<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.|
| [width](#width) | number | Component width.<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.| | [width](#width) | number | Component width.<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.|
| [imageSmoothingQuality](#imagesmoothingquality) | ImageSmoothingQuality | Quality of image smoothing. This attribute works only when **imageSmoothingEnabled** is set to **true**. Available values are as follows:<br>- **'low'**: low quality.<br>- **'medium'**: medium quality.<br>- **'high'**: high quality.<br>Default value: **'low'**<br>Since API version 9, this API is supported in ArkTS widgets.| | [imageSmoothingQuality](#imagesmoothingquality) |[ImageSmoothingQuality](ts-appendix-enums.md#imagesmoothingquality8) | Quality of image smoothing. This attribute works only when **imageSmoothingEnabled** is set to **true**.<br>Default value: **ImageSmoothingQuality.low**<br>Since API version 9, this API is supported in ArkTS widgets.|
| [direction](#direction) | CanvasDirection | Text direction used for drawing text. Available values are as follows:<br>- **'inherit'**: The text direction is inherited from the **\<Canvas>** component.<br>- **'ltr'**: The text direction is from left to right.<br>- **'rtl'**: The text direction is from right to left.<br>Default value: **'inherit'**<br>Since API version 9, this API is supported in ArkTS widgets.| | [direction](#direction) | [CanvasDirection](ts-appendix-enums.md#canvasdirection8) | Text direction used for drawing text.<br>Default value: **CanvasDirection.inherit**<br>Since API version 9, this API is supported in ArkTS widgets.|
| [filter](#filter) | string | Filter effect. Available values are as follows:<br>- **'none'**: no filter effect.<br>- **'blur'**: applies the Gaussian blur for the image.<br>- **'brightness'**: applies a linear multiplication to the image to make it look brighter or darker.<br>- **'contrast'**: adjusts the image contrast.<br>- **'grayscale'**: converts the image to a grayscale image.<br>- **'hue-rotate'**: applies hue rotation to the image.<br>- **'invert'**: inverts the input image.<br>- **'opacity'**: sets the opacity of the image.<br>- **'saturate'**: sets the saturation of the image.<br>- **'sepia'**: converts the image to dark brown.<br>Default value: **'none'**<br>Since API version 9, this API is supported in ArkTS widgets.| | [filter](#filter) | string | Filter effect. Available values are as follows:<br>- **'none'**: no filter effect.<br>- **'blur'**: applies the Gaussian blur for the image.<br>- **'brightness'**: applies a linear multiplication to the image to make it look brighter or darker.<br>- **'contrast'**: adjusts the image contrast.<br>- **'grayscale'**: converts the image to a grayscale image.<br>- **'hue-rotate'**: applies hue rotation to the image.<br>- **'invert'**: inverts the input image.<br>- **'opacity'**: sets the opacity of the image.<br>- **'saturate'**: sets the saturation of the image.<br>- **'sepia'**: converts the image to dark brown.<br>Default value: **'none'**<br>Since API version 9, this API is supported in ArkTS widgets.|
> **NOTE** > **NOTE**
...@@ -719,6 +719,136 @@ struct WidthExample { ...@@ -719,6 +719,136 @@ struct WidthExample {
![en-us_image_canvas_width](figures/en-us_image_canvas_width.png) ![en-us_image_canvas_width](figures/en-us_image_canvas_width.png)
### imageSmoothingQuality
```ts
// xxx.ets
@Entry
@Component
struct ImageSmoothingQualityDemo {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
private img:ImageBitmap = new ImageBitmap("common/images/example.jpg");
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
.width('100%')
.height('100%')
.backgroundColor('#ffff00')
.onReady(() =>{
let ctx = this.context
ctx.imageSmoothingEnabled = true
ctx.imageSmoothingQuality = 'high'
ctx.drawImage(this.img, 0, 0, 400, 200)
})
}
.width('100%')
.height('100%')
}
}
```
![ImageSmoothingQualityDemo](figures/ImageSmoothingQualityDemo.jpeg)
### direction
```ts
// xxx.ets
@Entry
@Component
struct DirectionDemo {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
.width('100%')
.height('100%')
.backgroundColor('#ffff00')
.onReady(() =>{
let ctx = this.context
ctx.font = '48px serif';
ctx.textAlign = 'start'
ctx.fillText("Hi ltr!", 200, 50);
ctx.direction = "rtl";
ctx.fillText("Hi rtl!", 200, 100);
})
}
.width('100%')
.height('100%')
}
}
```
![directionDemo](figures/directionDemo.jpeg)
### filter
```ts
// xxx.ets
@Entry
@Component
struct FilterDemo {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
private img:ImageBitmap = new ImageBitmap("common/images/example.jpg");
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
.width('100%')
.height('100%')
.backgroundColor('#ffff00')
.onReady(() =>{
let ctx = this.context
let img = this.img
ctx.drawImage(img, 0, 0, 100, 100);
ctx.filter = 'grayscale(50%)';
ctx.drawImage(img, 100, 0, 100, 100);
ctx.filter = 'sepia(60%)';
ctx.drawImage(img, 200, 0, 100, 100);
ctx.filter = 'saturate(30%)';
ctx.drawImage(img, 0, 100, 100, 100);
ctx.filter = 'hue-rotate(90degree)';
ctx.drawImage(img, 100, 100, 100, 100);
ctx.filter = 'invert(100%)';
ctx.drawImage(img, 200, 100, 100, 100);
ctx.filter = 'opacity(25%)';
ctx.drawImage(img, 0, 200, 100, 100);
ctx.filter = 'brightness(0.4)';
ctx.drawImage(img, 100, 200, 100, 100);
ctx.filter = 'contrast(200%)';
ctx.drawImage(img, 200, 200, 100, 100);
ctx.filter = 'blur(5px)';
ctx.drawImage(img, 0, 300, 100, 100);
let result = ctx.toDataURL()
console.info(result)
})
}
.width('100%')
.height('100%')
}
}
```
![filterDemo](figures/filterDemo.jpeg)
## Methods ## Methods
...@@ -734,8 +864,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -734,8 +864,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | ------------- | | ------ | ------ | ---- | ---- | ------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle.| | x | number | Yes | 0 | X coordinate of the upper left corner of the rectangle.|
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle.| | y | number | Yes | 0 | Y coordinate of the upper left corner of the rectangle.|
| width | number | Yes | 0 | Width of the rectangle. | | width | number | Yes | 0 | Width of the rectangle. |
| height | number | Yes | 0 | Height of the rectangle. | | height | number | Yes | 0 | Height of the rectangle. |
...@@ -780,8 +910,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -780,8 +910,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ------------ | | ---- | ------ | ---- | ---- | ------------ |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle.| | x | number | Yes | 0 | X coordinate of the upper left corner of the rectangle.|
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle.| | y | number | Yes | 0 | Y coordinate of the upper left corner of the rectangle.|
| w | number | Yes | 0 | Width of the rectangle. | | w | number | Yes | 0 | Width of the rectangle. |
| h | number | Yes | 0 | Height of the rectangle. | | h | number | Yes | 0 | Height of the rectangle. |
...@@ -826,8 +956,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -826,8 +956,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ------------- | | ---- | ------ | ---- | ---- | ------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle.| | x | number | Yes | 0 | X coordinate of the upper left corner of the rectangle.|
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle.| | y | number | Yes | 0 | Y coordinate of the upper left corner of the rectangle.|
| w | number | Yes | 0 | Width of the rectangle. | | w | number | Yes | 0 | Width of the rectangle. |
| h | number | Yes | 0 | Height of the rectangle. | | h | number | Yes | 0 | Height of the rectangle. |
...@@ -875,8 +1005,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -875,8 +1005,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | ------ | ---- | ---- | --------------- | | -------- | ------ | ---- | ---- | --------------- |
| text | string | Yes | '' | Text to draw. | | text | string | Yes | '' | Text to draw. |
| x | number | Yes | 0 | X-coordinate of the lower left corner of the text.| | x | number | Yes | 0 | X coordinate of the lower left corner of the text.|
| y | number | Yes | 0 | Y-coordinate of the lower left corner of the text.| | y | number | Yes | 0 | Y coordinate of the lower left corner of the text.|
| maxWidth | number | No | - | Maximum width allowed for the text. | | maxWidth | number | No | - | Maximum width allowed for the text. |
**Example** **Example**
...@@ -922,8 +1052,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -922,8 +1052,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | ------ | ---- | ---- | --------------- | | -------- | ------ | ---- | ---- | --------------- |
| text | string | Yes | '' | Text to draw. | | text | string | Yes | '' | Text to draw. |
| x | number | Yes | 0 | X-coordinate of the lower left corner of the text.| | x | number | Yes | 0 | X coordinate of the lower left corner of the text.|
| y | number | Yes | 0 | Y-coordinate of the lower left corner of the text.| | y | number | Yes | 0 | Y coordinate of the lower left corner of the text.|
| maxWidth | number | No | - | Maximum width of the text to be drawn. | | maxWidth | number | No | - | Maximum width of the text to be drawn. |
**Example** **Example**
...@@ -1130,8 +1260,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -1130,8 +1260,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------- | | ---- | ------ | ---- | ---- | --------- |
| x | number | Yes | 0 | X-coordinate of the target position.| | x | number | Yes | 0 | X coordinate of the target position.|
| y | number | Yes | 0 | Y-coordinate of the target position.| | y | number | Yes | 0 | Y coordinate of the target position.|
**Example** **Example**
...@@ -1177,8 +1307,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -1177,8 +1307,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------- | | ---- | ------ | ---- | ---- | --------- |
| x | number | Yes | 0 | X-coordinate of the target position.| | x | number | Yes | 0 | X coordinate of the target position.|
| y | number | Yes | 0 | Y-coordinate of the target position.| | y | number | Yes | 0 | Y coordinate of the target position.|
**Example** **Example**
...@@ -1319,12 +1449,12 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -1319,12 +1449,12 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | -------------- | | ---- | ------ | ---- | ---- | -------------- |
| cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve.| | cp1x | number | Yes | 0 | X coordinate of the first parameter of the bezier curve.|
| cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve.| | cp1y | number | Yes | 0 | Y coordinate of the first parameter of the bezier curve.|
| cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve.| | cp2x | number | Yes | 0 | X coordinate of the second parameter of the bezier curve.|
| cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve.| | cp2y | number | Yes | 0 | Y coordinate of the second parameter of the bezier curve.|
| x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | | x | number | Yes | 0 | X coordinate of the end point on the bezier curve. |
| y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | | y | number | Yes | 0 | Y coordinate of the end point on the bezier curve. |
**Example** **Example**
...@@ -1370,10 +1500,10 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -1370,10 +1500,10 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ----------- | | ---- | ------ | ---- | ---- | ----------- |
| cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter.| | cpx | number | Yes | 0 | X coordinate of the bezier curve parameter.|
| cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter.| | cpy | number | Yes | 0 | Y coordinate of the bezier curve parameter.|
| x | number | Yes | 0 | X-coordinate of the end point on the bezier curve.| | x | number | Yes | 0 | X coordinate of the end point on the bezier curve.|
| y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve.| | y | number | Yes | 0 | Y coordinate of the end point on the bezier curve.|
**Example** **Example**
...@@ -1419,8 +1549,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -1419,8 +1549,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---------------- | ------- | ---- | ----- | ---------- | | ---------------- | ------- | ---- | ----- | ---------- |
| x | number | Yes | 0 | X-coordinate of the center point of the arc.| | x | number | Yes | 0 | X coordinate of the center point of the arc.|
| y | number | Yes | 0 | Y-coordinate of the center point of the arc.| | y | number | Yes | 0 | Y coordinate of the center point of the arc.|
| radius | number | Yes | 0 | Radius of the arc. | | radius | number | Yes | 0 | Radius of the arc. |
| startAngle | number | Yes | 0 | Start radian of the arc. | | startAngle | number | Yes | 0 | Start radian of the arc. |
| endAngle | number | Yes | 0 | End radian of the arc. | | endAngle | number | Yes | 0 | End radian of the arc. |
...@@ -1469,10 +1599,10 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -1469,10 +1599,10 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | --------------- | | ------ | ------ | ---- | ---- | --------------- |
| x1 | number | Yes | 0 | X-coordinate of the first point on the arc.| | x1 | number | Yes | 0 | X coordinate of the first point on the arc.|
| y1 | number | Yes | 0 | Y-coordinate of the first point on the arc.| | y1 | number | Yes | 0 | Y coordinate of the first point on the arc.|
| x2 | number | Yes | 0 | X-coordinate of the second point on the arc.| | x2 | number | Yes | 0 | X coordinate of the second point on the arc.|
| y2 | number | Yes | 0 | Y-coordinate of the second point on the arc.| | y2 | number | Yes | 0 | Y coordinate of the second point on the arc.|
| radius | number | Yes | 0 | Radius of the arc. | | radius | number | Yes | 0 | Radius of the arc. |
**Example** **Example**
...@@ -1518,8 +1648,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -1518,8 +1648,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---------------- | ------- | ---- | ----- | ---------------------------------------- | | ---------------- | ------- | ---- | ----- | ---------------------------------------- |
| x | number | Yes | 0 | X-coordinate of the ellipse center. | | x | number | Yes | 0 | X coordinate of the ellipse center. |
| y | number | Yes | 0 | Y-coordinate of the ellipse center. | | y | number | Yes | 0 | Y coordinate of the ellipse center. |
| radiusX | number | Yes | 0 | Ellipse radius on the x-axis. | | radiusX | number | Yes | 0 | Ellipse radius on the x-axis. |
| radiusY | number | Yes | 0 | Ellipse radius on the y-axis. | | radiusY | number | Yes | 0 | Ellipse radius on the y-axis. |
| rotation | number | Yes | 0 | Rotation angle of the ellipse. The unit is radian. | | rotation | number | Yes | 0 | Rotation angle of the ellipse. The unit is radian. |
...@@ -1570,8 +1700,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -1570,8 +1700,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ------------- | | ---- | ------ | ---- | ---- | ------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle.| | x | number | Yes | 0 | X coordinate of the upper left corner of the rectangle.|
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle.| | y | number | Yes | 0 | Y coordinate of the upper left corner of the rectangle.|
| w | number | Yes | 0 | Width of the rectangle. | | w | number | Yes | 0 | Width of the rectangle. |
| h | number | Yes | 0 | Height of the rectangle. | | h | number | Yes | 0 | Height of the rectangle. |
...@@ -1802,97 +1932,6 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -1802,97 +1932,6 @@ Since API version 9, this API is supported in ArkTS widgets.
![en-us_image_000000127777779](figures/en-us_image_000000127777779.png) ![en-us_image_000000127777779](figures/en-us_image_000000127777779.png)
### filter
filter(filter: string): void
Provides filter effects.
Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | ---------------------------------------- |
| filter | string | Yes | - | Filter functions. Available values are as follows:<br>- **'none'**: no filter effect.<br>- **'blur'**: applies the Gaussian blur for the image.<br>- **'brightness'**: applies a linear multiplication to the image to make it look brighter or darker.<br>- **'contrast'**: adjusts the image contrast.<br>- **'grayscale'**: converts the image to a grayscale image.<br>- **'hue-rotate'**: applies hue rotation to the image.<br>- **'invert'**: inverts the input image.<br>- **'opacity'**: sets the opacity of the image.<br>- **'saturate'**: sets the saturation of the image.<br>- **'sepia'**: converts the image to dark brown.<br>Default value: **'none'**|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct FilterDemo {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
private img:ImageBitmap = new ImageBitmap("common/images/example.jpg");
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
.width('100%')
.height('100%')
.backgroundColor('#ffff00')
.onReady(() =>{
let ctx = this.context
let img = this.img
ctx.drawImage(img, 0, 0, 100, 100);
ctx.filter = 'grayscale(50%)';
ctx.drawImage(img, 100, 0, 100, 100);
ctx.filter = 'sepia(60%)';
ctx.drawImage(img, 200, 0, 100, 100);
ctx.filter = 'saturate(30%)';
ctx.drawImage(img, 0, 100, 100, 100);
ctx.filter = 'hue-rotate(90degree)';
ctx.drawImage(img, 100, 100, 100, 100);
ctx.filter = 'invert(100%)';
ctx.drawImage(img, 200, 100, 100, 100);
ctx.filter = 'opacity(25%)';
ctx.drawImage(img, 0, 200, 100, 100);
ctx.filter = 'brightness(0.4)';
ctx.drawImage(img, 100, 200, 100, 100);
ctx.filter = 'contrast(200%)';
ctx.drawImage(img, 200, 200, 100, 100);
ctx.filter = 'blur(5px)';
ctx.drawImage(img, 0, 300, 100, 100);
let result = ctx.toDataURL()
console.info(result)
})
}
.width('100%')
.height('100%')
}
}
```
![filterDemo](figures/filterDemo.jpeg)
### getTransform
getTransform(): Matrix2D
Obtains the current transformation matrix being applied to the context. This API is a void API.
Since API version 9, this API is supported in ArkTS widgets.
**Return value**
| Type | Description |
| ---------------------------------------- | ----- |
| [Matrix2D](ts-components-canvas-matrix2d.md#Matrix2D) | **Matrix2D** object.|
### resetTransform ### resetTransform
resetTransform(): void resetTransform(): void
...@@ -1902,47 +1941,6 @@ Resets the current transform to the identity matrix. This API is a void API. ...@@ -1902,47 +1941,6 @@ Resets the current transform to the identity matrix. This API is a void API.
Since API version 9, this API is supported in ArkTS widgets. Since API version 9, this API is supported in ArkTS widgets.
### direction
direction(direction: CanvasDirection): void
Sets the current text direction used to draw text.
Since API version 9, this API is supported in ArkTS widgets.
**Example**
```ts
// xxx.ets
@Entry
@Component
struct DirectionDemo {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
.width('100%')
.height('100%')
.backgroundColor('#ffff00')
.onReady(() =>{
let ctx = this.context
ctx.font = '48px serif';
ctx.textAlign = 'start'
ctx.fillText("Hi ltr!", 200, 50);
ctx.direction = "rtl";
ctx.fillText("Hi rtl!", 200, 100);
})
}
.width('100%')
.height('100%')
}
}
```
![directionDemo](figures/directionDemo.jpeg)
### rotate ### rotate
rotate(angle: number): void rotate(angle: number): void
...@@ -2152,7 +2150,7 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -2152,7 +2150,7 @@ Since API version 9, this API is supported in ArkTS widgets.
setTransform(transform?: Matrix2D): void setTransform(transform?: Matrix2D): void
Resets the current transformation to the identity matrix, and then creates a new transformation matrix based on the specified **Matrix2D** object. This API is a void API. Resets the current transformation to the identity matrix, and then creates a new transformation matrix based on the specified **Matrix2D** object.
Since API version 9, this API is supported in ArkTS widgets. Since API version 9, this API is supported in ArkTS widgets.
...@@ -2162,6 +2160,66 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -2162,6 +2160,66 @@ Since API version 9, this API is supported in ArkTS widgets.
| --------- | ---------------------------------------- | ---- | ---- | ----- | | --------- | ---------------------------------------- | ---- | ---- | ----- |
| transform | [Matrix2D](ts-components-canvas-matrix2d.md#Matrix2D) | No | null | Transformation matrix.| | transform | [Matrix2D](ts-components-canvas-matrix2d.md#Matrix2D) | No | null | Transformation matrix.|
### getTransform
getTransform(): Matrix2D
Obtains the current transformation matrix being applied to the context.
Since API version 9, this API is supported in ArkTS widgets.
**Return value**
| Type | Description |
| ---------------------------------------- | ----- |
| [Matrix2D](ts-components-canvas-matrix2d.md#Matrix2D) | **Matrix2D** object.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct TransFormDemo {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context1: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
private context2: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('context1');
Canvas(this.context1)
.width('230vp')
.height('120vp')
.backgroundColor('#ffff00')
.onReady(() =>{
this.context1.fillRect(50, 50, 50, 50);
this.context1.setTransform(1.2, Math.PI/8, Math.PI/6, 0.5, 30, -25);
this.context1.fillRect(50, 50, 50, 50);
})
Text('context2');
Canvas(this.context2)
.width('230vp')
.height('120vp')
.backgroundColor('#0ffff0')
.onReady(() =>{
this.context2.fillRect(50, 50, 50, 50);
let storedTransform = this.context1.getTransform();
console.log("Matrix [scaleX = " + storedTransform.scaleX + ", scaleY = " + storedTransform.scaleY +
", rotateX = " + storedTransform.rotateX + ", rotateY = " + storedTransform.rotateY +
", translateX = " + storedTransform.translateX + ", translateY = " + storedTransform.translateY + "]")
this.context2.setTransform(storedTransform);
this.context2.fillRect(50,50,50,50);
})
}
.width('100%')
.height('100%')
}
}
```
![en-us_image_0000001219982726.png](figures/en-us_image_0000001219982726.png)
### translate ### translate
translate(x: number, y: number): void translate(x: number, y: number): void
...@@ -2225,12 +2283,12 @@ Since API version 9, this API is supported in ArkTS widgets, except that **Pixel ...@@ -2225,12 +2283,12 @@ Since API version 9, this API is supported in ArkTS widgets, except that **Pixel
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ----- | ---------------------------------------- | ---- | ---- | ---------------------------------------- | | ----- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
| image | [ImageBitmap](ts-components-canvas-imagebitmap.md) or [PixelMap](../apis/js-apis-image.md#pixelmap7)| Yes | null | Image resource. For details, see **ImageBitmap** or PixelMap. | | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) or [PixelMap](../apis/js-apis-image.md#pixelmap7)| Yes | null | Image resource. For details, see **ImageBitmap** or PixelMap. |
| sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | | sx | number | No | 0 | X coordinate of the upper left corner of the rectangle used to crop the source image. |
| sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | | sy | number | No | 0 | Y coordinate of the upper left corner of the rectangle used to crop the source image. |
| sw | number | No | 0 | Target width to crop the source image. | | sw | number | No | 0 | Target width to crop the source image. |
| sh | number | No | 0 | Target height to crop the source image. | | sh | number | No | 0 | Target height to crop the source image. |
| dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. | | dx | number | Yes | 0 | X coordinate of the upper left corner of the drawing area on the canvas. |
| dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. | | dy | number | Yes | 0 | Y coordinate of the upper left corner of the drawing area on the canvas. |
| dw | number | No | 0 | Width of the drawing area. If the width of the drawing area is different from that of the cropped image, the latter will be stretched or compressed to the former.| | dw | number | No | 0 | Width of the drawing area. If the width of the drawing area is different from that of the cropped image, the latter will be stretched or compressed to the former.|
| dh | number | No | 0 | Height of the drawing area. If the height of the drawing area is different from that of the cropped image, the latter will be stretched or compressed to the former.| | dh | number | No | 0 | Height of the drawing area. If the height of the drawing area is different from that of the cropped image, the latter will be stretched or compressed to the former.|
...@@ -2310,8 +2368,8 @@ Obtains the **[PixelMap](../apis/js-apis-image.md#pixelmap7)** object created wi ...@@ -2310,8 +2368,8 @@ Obtains the **[PixelMap](../apis/js-apis-image.md#pixelmap7)** object created wi
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------------- | | ---- | ------ | ---- | ---- | --------------- |
| sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area.| | sx | number | Yes | 0 | X coordinate of the upper left corner of the output area.|
| sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area.| | sy | number | Yes | 0 | Y coordinate of the upper left corner of the output area.|
| sw | number | Yes | 0 | Width of the output area. | | sw | number | Yes | 0 | Width of the output area. |
| sh | number | Yes | 0 | Height of the output area. | | sh | number | Yes | 0 | Height of the output area. |
...@@ -2333,8 +2391,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -2333,8 +2391,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------------- | | ---- | ------ | ---- | ---- | --------------- |
| sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area.| | sx | number | Yes | 0 | X coordinate of the upper left corner of the output area.|
| sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area.| | sy | number | Yes | 0 | Y coordinate of the upper left corner of the output area.|
| sw | number | Yes | 0 | Width of the output area. | | sw | number | Yes | 0 | Width of the output area. |
| sh | number | Yes | 0 | Height of the output area. | | sh | number | Yes | 0 | Height of the output area. |
...@@ -2537,52 +2595,6 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -2537,52 +2595,6 @@ Since API version 9, this API is supported in ArkTS widgets.
![en-us_image_000000127777778](figures/en-us_image_000000127777778.png) ![en-us_image_000000127777778](figures/en-us_image_000000127777778.png)
### imageSmoothingQuality
imageSmoothingQuality(quality: imageSmoothingQuality)
Sets the quality of image smoothing.
Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name | Type | Description |
| ------- | --------------------- | ---------------------------------------- |
| quality | imageSmoothingQuality | Quality of image smoothing.<br>- **'low'**: low quality.<br>- **'medium'**: medium quality.<br>- **'high'**: high quality.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct ImageSmoothingQualityDemo {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
private img:ImageBitmap = new ImageBitmap("common/images/example.jpg");
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
.width('100%')
.height('100%')
.backgroundColor('#ffff00')
.onReady(() =>{
let ctx = this.context
ctx.imageSmoothingEnabled = true
ctx.imageSmoothingQuality = 'high'
ctx.drawImage(this.img, 0, 0, 400, 200)
})
}
.width('100%')
.height('100%')
}
}
```
![ImageSmoothingQualityDemo](figures/ImageSmoothingQualityDemo.jpeg)
### transferFromImageBitmap ### transferFromImageBitmap
transferFromImageBitmap(bitmap: ImageBitmap): void transferFromImageBitmap(bitmap: ImageBitmap): void
...@@ -2775,10 +2787,10 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -2775,10 +2787,10 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | -------- | | ---- | ------ | ---- | ---- | -------- |
| x0 | number | Yes | 0 | X-coordinate of the start point.| | x0 | number | Yes | 0 | X coordinate of the start point.|
| y0 | number | Yes | 0 | Y-coordinate of the start point.| | y0 | number | Yes | 0 | Y coordinate of the start point.|
| x1 | number | Yes | 0 | X-coordinate of the end point.| | x1 | number | Yes | 0 | X coordinate of the end point.|
| y1 | number | Yes | 0 | Y-coordinate of the end point.| | y1 | number | Yes | 0 | Y coordinate of the end point.|
**Example** **Example**
...@@ -2826,11 +2838,11 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -2826,11 +2838,11 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ----------------- | | ---- | ------ | ---- | ---- | ----------------- |
| x0 | number | Yes | 0 | X-coordinate of the center of the start circle. | | x0 | number | Yes | 0 | X coordinate of the center of the start circle. |
| y0 | number | Yes | 0 | Y-coordinate of the center of the start circle. | | y0 | number | Yes | 0 | Y coordinate of the center of the start circle. |
| r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number.| | r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number.|
| x1 | number | Yes | 0 | X-coordinate of the center of the end circle. | | x1 | number | Yes | 0 | X coordinate of the center of the end circle. |
| y1 | number | Yes | 0 | Y-coordinate of the center of the end circle. | | y1 | number | Yes | 0 | Y coordinate of the center of the end circle. |
| r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number.| | r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number.|
**Example** **Example**
...@@ -2877,8 +2889,8 @@ Creates a conic gradient. ...@@ -2877,8 +2889,8 @@ Creates a conic gradient.
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---------- | ------ | ---- | ---- | ----------------------------------- | | ---------- | ------ | ---- | ---- | ----------------------------------- |
| startAngle | number | Yes | 0 | Angle at which the gradient starts, in radians. The angle measurement starts horizontally from the right side of the center and moves clockwise.| | startAngle | number | Yes | 0 | Angle at which the gradient starts, in radians. The angle measurement starts horizontally from the right side of the center and moves clockwise.|
| x | number | Yes | 0 | X-coordinate of the center of the conic gradient, in vp. | | x | number | Yes | 0 | X coordinate of the center of the conic gradient, in vp. |
| y | number | Yes | 0 | X-coordinate of the center of the conic gradient, in vp. | | y | number | Yes | 0 | Y coordinate of the center of the conic gradient, in vp. |
**Example** **Example**
......
...@@ -22,7 +22,7 @@ Defines and shows the action sheet. ...@@ -22,7 +22,7 @@ Defines and shows the action sheet.
| ---------- | -------------------------- | ------- | ----------------------------- | | ---------- | -------------------------- | ------- | ----------------------------- |
| title | [Resource](ts-types.md#resource) \| string | Yes | Title of the dialog box.| | title | [Resource](ts-types.md#resource) \| string | Yes | Title of the dialog box.|
| message | [Resource](ts-types.md#resource) \| string | Yes | Content of the dialog box. | | message | [Resource](ts-types.md#resource) \| string | Yes | Content of the dialog box. |
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true**| | autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true**<br>The value **true** means to close the dialog box when the overlay is clicked, and **false** means the opposite.|
| confirm | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>action: () =&gt; void<br>} | No | Text content of the confirm button and callback upon button clicking.<br>Default value:<br>**value**: button text.<br>**action**: callback upon button clicking.| | confirm | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>action: () =&gt; void<br>} | No | Text content of the confirm button and callback upon button clicking.<br>Default value:<br>**value**: button text.<br>**action**: callback upon button clicking.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked. | | cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked. |
| alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Bottom**| | alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Bottom**|
......
...@@ -25,8 +25,8 @@ You can set the text content and response callback for an alert dialog box. ...@@ -25,8 +25,8 @@ You can set the text content and response callback for an alert dialog box.
| confirm | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void<br>} | No | Text content, text color, background color, and click callback of the confirm button.| | confirm | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void<br>} | No | Text content, text color, background color, and click callback of the confirm button.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked.| | cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked.|
| alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**| | alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
| offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.| | offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.<br>Default value: **{ dx: 0 , dy: 0 }**|
| gridCount | number | No | Number of grid columns occupied by the width of the dialog box.| | gridCount | number | No | Number of grid columns occupied by the width of the dialog box.<br>Default value: **4**|
## AlertDialogParamWithButtons ## AlertDialogParamWithButtons
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -35,7 +35,7 @@ You can set the text content and response callback for an alert dialog box. ...@@ -35,7 +35,7 @@ You can set the text content and response callback for an alert dialog box.
| message | [ResourceStr](ts-types.md#resourcestr) | Yes | Content of the dialog box. | | message | [ResourceStr](ts-types.md#resourcestr) | Yes | Content of the dialog box. |
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true** | | autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true** |
| primaryButton | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No| Text content, text color, background color, and click callback of the primary button.| | primaryButton | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No| Text content, text color, background color, and click callback of the primary button.|
| secondaryButton | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No | Text content, text color, background color, and click callback of the primary button.| | secondaryButton | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No | Text content, text color, background color, and click callback of the secondary button.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked. | | cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked. |
| alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**| | alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
| offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.| | offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.|
......
...@@ -11,9 +11,9 @@ You can set accessibility attributes and events for components. ...@@ -11,9 +11,9 @@ You can set accessibility attributes and events for components.
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| accessibilityGroup | boolean | Accessibility group. If this attribute is set to **true**, the component and all its child components form an entire selectable component, and the accessibility service will no longer be available for the content of its child components.<br>Default value: **false**| | accessibilityGroup | boolean | Accessibility group. If this attribute is set to **true**, the component and all its child components form an entire selectable component, and the accessibility service will no longer be available for the content of its child components.<br>Default value: **false**|
| accessibilityText | string | Accessibility text. If a component does not contain text information, it will not be read when the component is selected by the screen reader. In this case, the screen reader user cannot know which component is selected. To solve this problem, you can set this attribute for components without text information. When the component is selected by the screen reader, the specified accessibility text will be read, informing the user which component is selected.<br>**NOTE**<br>If a component with this attribute set contains text information, only the accessibility text will be read.<br>If a component with its **accessibilityGroup** attribute set to **true** does not have **accessibilityText** set and does not contain text information, text concatenation will be performed on its child components (depth first).| | accessibilityText | string | Accessibility text. If a component does not contain text information, it will not be read when the component is selected by the screen reader. In this case, the screen reader user cannot know which component is selected. To solve this problem, you can set this attribute for components without text information. When the component is selected by the screen reader, the specified accessibility text will be read, informing the user which component is selected.<br>Default value: **""**<br>**NOTE**<br>If a component with this attribute set contains text information, only the accessibility text will be read.<br>If a component with its **accessibilityGroup** attribute set to **true** does not have **accessibilityText** set and does not contain text information, text concatenation will be performed on its child components (depth first).|
| accessibilityDescription | string | Accessibility description. You can specify further explanation of the current component, for example, possible operation consequences, especially those that cannot be learned from component attributes and accessibility text. You can set a detailed description text for the attribute of the component to help users understand the operation to be performed. If a component contains both text information and the accessibility description, the text is read first and then the accessibility description, when the component is selected.| | accessibilityDescription | string | Accessibility description. You can specify further explanation of the current component, for example, possible operation consequences, especially those that cannot be learned from component attributes and accessibility text. If a component contains both text information and the accessibility description, the text is read first and then the accessibility description, when the component is selected.<br>Default value: **""**|
| accessibilityLevel | string | Accessibility importance, which is used to decide whether a component can be identified by the accessibility service.<br>The options are as follows:<br>**"auto"**: The value is converted to **"yes"** or **"no"** based on the component.<br>**"yes"**: The current component is selectable for the accessibility service.<br>**"no"**: The current component is not selectable for the accessibility service.<br>**"no-hide-descendants"**: The current component and all its child components are not selectable for the accessibility service.<br>**Default value**: **"auto"**<br>**NOTE**<br>When the **accessibilityLevel** attribute of the following components is set to **"auto"**, they are selectable for the accessibility service: Checkbox, CheckboxGroup, Gauge, Marquee, MenuItem, MenuItemGroup, Menu, Navigation, DatePicker, Progress, Radio, Rating, ScrollBar, Select, Slider, Stepper, Text, TextClock, TextPicker, TextTimer, TimePicker, Toggle, Web. | | accessibilityLevel | string | Accessibility importance, which is used to decide whether a component can be identified by the accessibility service.<br>The options are as follows:<br>**"auto"**: The value is converted to **"yes"** or **"no"** based on the component.<br>**"yes"**: The current component is selectable for the accessibility service.<br>**"no"**: The current component is not selectable for the accessibility service.<br>**"no-hide-descendants"**: The current component and all its child components are not selectable for the accessibility service.<br>**Default value**: **"auto"**<br>**NOTE**<br>When the **accessibilityLevel** attribute of the following components is set to **"auto"**, they are selectable for the accessibility service: Checkbox, CheckboxGroup, Gauge, Marquee, MenuItem, MenuItemGroup, Menu, Navigation, DatePicker, Progress, Radio, Rating, ScrollBar, Select, Slider, Stepper, Text, TextClock, TextPicker, TextTimer, TimePicker, Toggle, Web.|
## Example ## Example
......
...@@ -11,7 +11,7 @@ The visible area change event of a component refers to the change in the visual ...@@ -11,7 +11,7 @@ The visible area change event of a component refers to the change in the visual
| Name | Description | | Name | Description |
| ---------------------------------------- | ---------------------------------------- | | ---------------------------------------- | ---------------------------------------- |
| onVisibleAreaChange(ratios: Array\<number>, event: (isVisible: boolean, currentRatio: number) => void) | Called when the visual area of the component changes.<br>- **ratios**: threshold array. Each threshold represents a ratio of the component's visible area (that is, the area of the component that is visible on screen) to the component's total area. This callback is invoked when the ratio of the component's visible area to its total area is greater than or less than the threshold. The value range of the threshold is [0.0, 1.0]. If the threshold set exceeds this range, the value **0.0** or **1.0** will be used.<br>- **isVisible**: indicates whether the ratio of the component's visible area to its total area is greater than the threshold. The value **true** means that the ratio is greater than the threshold, and **false** means that the ratio is less than the threshold.<br>- **currentRatio**: ratio of the component's visible area to its total area when this callback is invoked.| | onVisibleAreaChange(ratios: Array\<number>, event: (isVisible: boolean, currentRatio: number) => void) | Called when the visual area of the component changes.<br>- **ratios**: threshold array. Each threshold represents a ratio of the component's visible area (that is, the area of the component that is visible on screen) to the component's total area. This callback is invoked when the ratio of the component's visible area to its total area is greater than or less than the threshold. The value range of the threshold is [0.0, 1.0]. If the threshold set exceeds this range, the value **0.0** or **1.0** will be used.<br>- **isVisible**: whether the ratio of the component's visible area to its total area is greater than the threshold. The value **true** means that the ratio is greater than the threshold, and **false** means that the ratio is less than the threshold.<br>- **currentRatio**: ratio of the component's visible area to its total area when this callback is invoked.<br>**NOTE**<br>This API applies only to the scenario where the component layout area exceeds or is not within the current screen display area. It does not apply to the scenario where the area becomes invisible due to component stacking or the visible area exceeds the allowed range as a result of calling transformation APIs such as **offset** or **translate**.|
## Example ## Example
...@@ -98,7 +98,7 @@ struct ScrollExample { ...@@ -98,7 +98,7 @@ struct ScrollExample {
.scrollable(ScrollDirection.Vertical) .scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.On) .scrollBar(BarState.On)
.scrollBarColor(Color.Gray) .scrollBarColor(Color.Gray)
.scrollBarWidth(30) .scrollBarWidth(10)
.onScroll((xOffset: number, yOffset: number) => { .onScroll((xOffset: number, yOffset: number) => {
console.info(xOffset + ' ' + yOffset) console.info(xOffset + ' ' + yOffset)
}) })
......
...@@ -230,23 +230,23 @@ The related JS database API is not used. ...@@ -230,23 +230,23 @@ The related JS database API is not used.
2. If the JS database API is used, find out the failure cause, for example, check whether **databaseAccess** is enabled. 2. If the JS database API is used, find out the failure cause, for example, check whether **databaseAccess** is enabled.
## 17100013 Memory Allocation Failure ## 17100013 Invalid Number of Sockets During Preconnection
**Error Message** **Error Message**
New failed, out of memeory. The number of preconnect sockets is invalid.
**Description** **Description**
Memory allocation failed due to insufficient memory. This error code is reported when the number of sockets to be preconnected is invalid.
**Possible Causes** **Possible Causes**
The data to send is too large. The number of sockets is less than or equal to 0 or greater than 6.
**Solution** **Solution**
Check the length of the data to be sent. Make sure the specified number of sockets is greater than 0 and less than or equal to 6.
## 17100014 Type and Value Mismatch ## 17100014 Type and Value Mismatch
...@@ -257,7 +257,7 @@ The type does not match with the value of the message. ...@@ -257,7 +257,7 @@ The type does not match with the value of the message.
**Description** **Description**
The type and value of the message do not match. This error code is reported when the type and value of the message do not match.
**Possible Causes** **Possible Causes**
...@@ -266,3 +266,22 @@ The value of the obtained message does not match the type of the message. ...@@ -266,3 +266,22 @@ The value of the obtained message does not match the type of the message.
**Solution** **Solution**
Call the API based on the message type to obtain the message value. For example, if the type is **BOOLEAN**, call the **GetBoolean** API to obtain the Boolean value. Call the API based on the message type to obtain the message value. For example, if the type is **BOOLEAN**, call the **GetBoolean** API to obtain the Boolean value.
## 17100015 Memory Allocation Failure
**Error Message**
New failed, out of memeory.
**Description**
This error code is reported when memory allocation failed due to insufficient memory.
**Possible Causes**
The data to send is too large.
**Solution**
Check the length of the data to be sent.
...@@ -951,10 +951,15 @@ Device security level management ...@@ -951,10 +951,15 @@ Device security level management
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | No | Yes | No | No | | Yes | No | Yes | Yes | No | Yes | No | No |
## SystemCapability.Security.Huks
Hardware Unique Key (HUK) management ## SystemCapability.Security.Huks.Core
Device key management - core capabilities
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | Yes | Yes | Yes | No | Yes | No | No |
## SystemCapability.Security.Huks.Extension
Device key management - extended capabilities
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | No | Yes | No | No | | Yes | No | Yes | Yes | No | Yes | No | No |
......
...@@ -89,7 +89,7 @@ The following example registers the **test()** function with the frontend page. ...@@ -89,7 +89,7 @@ The following example registers the **test()** function with the frontend page.
> **NOTE** > **NOTE**
> >
> If you use [registerJavaScriptProxy()](../reference/apis/js-apis-webview.md#registerjavascriptproxy) to register a function, call **[refresh()]**(../reference/apis/js-apis-webview.md#refresh) for the function to take effect. > If you use [registerJavaScriptProxy()](../reference/apis/js-apis-webview.md#registerjavascriptproxy) to register a function, call [refresh()](../reference/apis/js-apis-webview.md#refresh) for the function to take effect.
- Sample code for invoking application functions on the **index.html** frontend page: - Sample code for invoking application functions on the **index.html** frontend page:
...@@ -103,7 +103,7 @@ The following example registers the **test()** function with the frontend page. ...@@ -103,7 +103,7 @@ The following example registers the **test()** function with the frontend page.
<p id="demo"></p> <p id="demo"></p>
<script> <script>
function callArkTS() { function callArkTS() {
let str = testObjName.test(); let str = objName.test();
document.getElementById("demo").innerHTML = str; document.getElementById("demo").innerHTML = str;
console.info('ArkTS Hello World! :' + str); console.info('ArkTS Hello World! :' + str);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册