提交 7fde2e61 编写于 作者: E ester.zhou

Update docs (19569)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 67f0c4ea
# Updating Widget Content by State # Updating Widget Content by State
There are cases where multiple copies of the same widget are added to the home screen to accommodate different needs. In these cases, the widget content needs to be dynamically updated based on the state. This topic exemplifies how this is implemented.
There are cases where multiple copies of the same widget are added to the home screen to accommodate different needs. In these cases, the widget content needs to be dynamically updated based on the state. This topic exemplifies how this is implemented. In the following example, two weather widgets are added to the home screen: one for displaying the weather of London, and the other Beijing, both configured to be updated at 07:00 every morning. The widget provider detects the target city, and then displays the city-specific weather information on the widgets. In the following example, two copies of the weather widget are added to the home screen: one for displaying the weather of London, and the other Beijing, both configured to be updated at 07:00 every morning. The widget provider detects the target city, and then displays the city-specific weather information on the widgets.
- Widget configuration file: Configure the widget to be updated at 07:00 every morning. - Widget configuration file: Configure the widget to be updated at 07:00 every morning.
...@@ -94,7 +95,7 @@ There are cases where multiple copies of the same widget are added to the home s ...@@ -94,7 +95,7 @@ There are cases where multiple copies of the same widget are added to the home s
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import dataStorage from '@ohos.data.storage' import dataPreferences from '@ohos.data.preferences';
export default class EntryFormAbility extends FormExtensionAbility { export default class EntryFormAbility extends FormExtensionAbility {
onAddForm(want) { onAddForm(want) {
...@@ -102,10 +103,10 @@ There are cases where multiple copies of the same widget are added to the home s ...@@ -102,10 +103,10 @@ There are cases where multiple copies of the same widget are added to the home s
let isTempCard: boolean = want.parameters[formInfo.FormParam.TEMPORARY_KEY]; let isTempCard: boolean = want.parameters[formInfo.FormParam.TEMPORARY_KEY];
if (isTempCard === false) {// If the widget is a normal one, the widget information is persisted. if (isTempCard === false) {// If the widget is a normal one, the widget information is persisted.
console.info('Not temp card, init db for:' + formId); console.info('Not temp card, init db for:' + formId);
let storeDB = dataStorage.getStorageSync(this.context.filesDir + 'myStore') let storeDB = dataPreferences.getPreferences(this.context, 'mystore')
storeDB.putSync('A' + formId, 'false'); storeDB.put('A' + formId, 'false');
storeDB.putSync('B' + formId, 'false'); storeDB.put('B' + formId, 'false');
storeDB.flushSync(); storeDB.flush();
} }
let formData = {}; let formData = {};
return formBindingData.createFormBindingData(formData); return formBindingData.createFormBindingData(formData);
...@@ -113,24 +114,24 @@ There are cases where multiple copies of the same widget are added to the home s ...@@ -113,24 +114,24 @@ There are cases where multiple copies of the same widget are added to the home s
onRemoveForm(formId) { onRemoveForm(formId) {
console.info('onRemoveForm, formId:' + formId); console.info('onRemoveForm, formId:' + formId);
let storeDB = dataStorage.getStorageSync(this.context.filesDir + 'myStore') let storeDB = dataPreferences.getPreferences(this.context, 'mystore')
storeDB.deleteSync('A' + formId); storeDB.delete('A' + formId);
storeDB.deleteSync('B' + formId); storeDB.delete('B' + formId);
} }
// If the widget is a temporary one, it is recommended that the widget information be persisted when the widget is converted to a normal one. // If the widget is a temporary one, it is recommended that the widget information be persisted when the widget is converted to a normal one.
onCastToNormalForm(formId) { onCastToNormalForm(formId) {
console.info('onCastToNormalForm, formId:' + formId); console.info('onCastToNormalForm, formId:' + formId);
let storeDB = dataStorage.getStorageSync(this.context.filesDir + 'myStore') let storeDB = dataPreferences.getPreferences(this.context, 'myStore')
storeDB.putSync('A' + formId, 'false'); storeDB.put('A' + formId, 'false');
storeDB.putSync('B' + formId, 'false'); storeDB.put('B' + formId, 'false');
storeDB.flushSync(); storeDB.flush();
} }
onUpdateForm(formId) { onUpdateForm(formId) {
let storeDB = dataStorage.getStorageSync(this.context.filesDir + 'myStore') let storeDB = dataPreferences.getPreferences(this.context, 'myStore')
let stateA = storeDB.getSync('A' + formId, 'false').toString() let stateA = storeDB.get('A' + formId, 'false').toString()
let stateB = storeDB.getSync('B' + formId, 'false').toString() let stateB = storeDB.get('B' + formId, 'false').toString()
// Update textA in state A. // Update textA in state A.
if (stateA === 'true') { if (stateA === 'true') {
let formInfo = formBindingData.createFormBindingData({ let formInfo = formBindingData.createFormBindingData({
...@@ -150,17 +151,17 @@ There are cases where multiple copies of the same widget are added to the home s ...@@ -150,17 +151,17 @@ There are cases where multiple copies of the same widget are added to the home s
onFormEvent(formId, message) { onFormEvent(formId, message) {
// Store the widget state. // Store the widget state.
console.info('onFormEvent formId:' + formId + 'msg:' + message); console.info('onFormEvent formId:' + formId + 'msg:' + message);
let storeDB = dataStorage.getStorageSync(this.context.filesDir + 'myStore') let storeDB = dataPreferences.getPreferences(this.context, 'myStore')
let msg = JSON.parse(message) let msg = JSON.parse(message)
if (msg.selectA != undefined) { if (msg.selectA != undefined) {
console.info('onFormEvent selectA info:' + msg.selectA); console.info('onFormEvent selectA info:' + msg.selectA);
storeDB.putSync('A' + formId, msg.selectA); storeDB.put('A' + formId, msg.selectA);
} }
if (msg.selectB != undefined) { if (msg.selectB != undefined) {
console.info('onFormEvent selectB info:' + msg.selectB); console.info('onFormEvent selectB info:' + msg.selectB);
storeDB.putSync('B' + formId, msg.selectB); storeDB.put('B' + formId, msg.selectB);
} }
storeDB.flushSync(); storeDB.flush();
} }
}; };
``` ```
...@@ -168,4 +169,4 @@ There are cases where multiple copies of the same widget are added to the home s ...@@ -168,4 +169,4 @@ There are cases where multiple copies of the same widget are added to the home s
> **NOTE** > **NOTE**
> >
> When the local database is used for widget information persistence, it is recommended that [TEMPORARY_KEY](../reference/apis/js-apis-app-form-formInfo.md#formparam) be used to determine whether the currently added widget is a normal one in the [onAddForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onaddform) lifecycle callback. If the widget is a normal one, the widget information is directly persisted. If the widget is a temporary one, the widget information is persisted when the widget is converted to a normal one ([onCastToNormalForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#oncasttonormalform)). In addition, the persistent widget information needs to be deleted when the widget is destroyed ([onRemoveForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onremoveform)), preventing the database size from continuously increasing due to repeated widget addition and deletion. > When the local database is used for widget information persistence, it is recommended that [TEMPORARY_KEY](../reference/apis/js-apis-app-form-formInfo.md#formparam) be used in the [onAddForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onaddform) lifecycle callback to determine whether the currently added widget is a normal one. If the widget is a normal one, the widget information is directly persisted. If the widget is a temporary one, the widget information is persisted when the widget is converted to a normal one ([onCastToNormalForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#oncasttonormalform)). In addition, the persistent widget information needs to be deleted when the widget is destroyed ([onRemoveForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onremoveform)), preventing the database size from continuously increasing due to repeated widget addition and deletion.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
- [Full SDK Compilation](full-sdk-compile-guide.md) - [Full SDK Compilation](full-sdk-compile-guide.md)
- [Switching to Full SDK](full-sdk-switch-guide.md) - [Switching to Full SDK](full-sdk-switch-guide.md)
- [Application Model Development](faqs-ability.md) - [Application Model Development](faqs-ability.md)
- ArkUI Framework Development (ArkTS) - ArkUI Development (ArkTS)
- [ArkTS Syntax Usage](faqs-arkui-arkts.md) - [ArkTS Syntax Usage](faqs-arkui-arkts.md)
- [ArkUI Component Development (ArkTS)](faqs-arkui-component.md) - [ArkUI Component Development (ArkTS)](faqs-arkui-component.md)
- [ArkUI Layout Development (ArkTS)](faqs-arkui-layout.md) - [ArkUI Layout Development (ArkTS)](faqs-arkui-layout.md)
......
...@@ -5,6 +5,8 @@ The **font** module provides APIs for registering custom fonts. ...@@ -5,6 +5,8 @@ The **font** module provides APIs for registering custom fonts.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import ## Modules to Import
...@@ -62,3 +64,104 @@ struct FontExample { ...@@ -62,3 +64,104 @@ struct FontExample {
} }
} }
``` ```
## font.getSystemFontList
getSystemFontList(): Array\<string>
Obtains the list of supported fonts.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Return value**
| Type | Description |
| -------------------- | ----------------- |
| Array\<string> | List of supported fonts. |
## Example
```ts
// xxx.ets
import font from '@ohos.font';
@Entry
@Component
struct FontExample {
fontList: Array<string>;
build() {
Column() {
Button("getSystemFontList")
.width('60%')
.height('6%')
.onClick(()=>{
this.fontList = font.getSystemFontList()
})
}.width('100%')
}
}
```
## font.getFontByName
getFontByName(fontName: string): FontInfo;
Obtains information about a system font based on the font name.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | --------- | ------- | ------------ |
| fontName | string | Yes | System font name.|
**Return value**
| Type | Description |
| ---------------- | ---------------------------- |
| FontInfo | Information about the system font. |
## FontInfo
| Name | Type | Description |
| -------------- | ------- | ------------------------- |
| path | string | File path of the system font. |
| postScriptName | string | PostScript name of the system font.|
| fullName | string | Name of the system font. |
| family | string | Family of the system font. |
| subfamily | string | Subfamily of the system font. |
| weight | number | Weight of the system font. |
| width | number | Width of the system font. |
| italic | boolean | Whether the system font is italic. |
| monoSpace | boolean | Whether the system font is monospaced. |
| symbolic | boolean | Whether the system font supports symbols. |
```ts
// xxx.ets
import font from '@ohos.font';
@Entry
@Component
struct FontExample {
fontList: Array<string>;
fontInfo: font.FontInfo;
build() {
Column() {
Button("getFontByName")
.onClick(() => {
this.fontInfo = font.getFontByName('HarmonyOS Sans Italic')
console.log("getFontByName(): path = " + this.fontInfo.path)
console.log("getFontByName(): postScriptName = " + this.fontInfo.postScriptName)
console.log("getFontByName(): fullName = " + this.fontInfo.fullName)
console.log("getFontByName(): Family = " + this.fontInfo.family)
console.log("getFontByName(): Subfamily = " + this.fontInfo.subfamily)
console.log("getFontByName(): weight = " + this.fontInfo.weight)
console.log("getFontByName(): width = " + this.fontInfo.width)
console.log("getFontByName(): italic = " + this.fontInfo.italic)
console.log("getFontByName(): monoSpace = " + this.fontInfo.monoSpace)
console.log("getFontByName(): symbolic = " + this.fontInfo.symbolic)
})
}.width('100%')
}
}
```
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
- [Mouse Event](ts-universal-mouse-key.md) - [Mouse Event](ts-universal-mouse-key.md)
- [Component Area Change Event](ts-universal-component-area-change-event.md) - [Component Area Change Event](ts-universal-component-area-change-event.md)
- [Visible Area Change Event](ts-universal-component-visible-area-change-event.md) - [Visible Area Change Event](ts-universal-component-visible-area-change-event.md)
- [Custom Keyboard Shortcuts](ts-universal-events-keyboardshortcut.md) - [Component Keyboard Shortcut Event](ts-universal-events-keyboardshortcut.md)
- Universal Attributes - Universal Attributes
- [Size](ts-universal-attributes-size.md) - [Size](ts-universal-attributes-size.md)
- [Location](ts-universal-attributes-location.md) - [Location](ts-universal-attributes-location.md)
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
- Touch Interactions - Touch Interactions
- [Touch Target](ts-universal-attributes-touch-target.md) - [Touch Target](ts-universal-attributes-touch-target.md)
- [Hit Test Control](ts-universal-attributes-hit-test-behavior.md) - [Hit Test Control](ts-universal-attributes-hit-test-behavior.md)
- Touch Interactions - Transition
- [Modal Transition](ts-universal-attributes-modal-transition.md) - [Modal Transition](ts-universal-attributes-modal-transition.md)
- [Sheet Transition](ts-universal-attributes-sheet-transition.md) - [Sheet Transition](ts-universal-attributes-sheet-transition.md)
- [Obscuring](ts-universal-attributes-obscured.md) - [Obscuring](ts-universal-attributes-obscured.md)
......
...@@ -12,7 +12,7 @@ Click control attributes are used to set whether a component can respond to fing ...@@ -12,7 +12,7 @@ Click control attributes are used to set whether a component can respond to fing
| Name | Type| Description | | Name | Type| Description |
| ----------- | -------- | ------------------------ | | ----------- | -------- | ------------------------ |
| touchable | boolean | Whether the component can respond to finger interactions such as click and touch events.<br>Default value: **true**| | touchable<sup>(deprecated)</sup> | boolean | Whether the component can respond to finger interactions such as click and touch events.<br>Default value: **true**<br>**NOTE**<br>This API is deprecated since API version 9. You are advised to use [hitTestBehavior](ts-universal-attributes-hit-test-behavior.md) instead.|
## Example ## Example
......
# Custom Keyboard Shortcuts # Component Keyboard Shortcut Event
You can set one or more custom keyboard shortcuts for a component. The behavior of these keyboard shortcuts is the same as that of clicks. Components can respond to custom keyboard shortcuts even when they are not focused. You can set one or more custom keyboard shortcuts for a component. The behavior of these keyboard shortcuts is the same as that of clicks. Components can respond to custom keyboard shortcuts even when they are not focused.
...@@ -12,23 +12,23 @@ keyboardShortcut(value: string | [FunctionKey], keys: Array<[ModifierKey]>) ...@@ -12,23 +12,23 @@ keyboardShortcut(value: string | [FunctionKey], keys: Array<[ModifierKey]>)
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------ | ------------------------------------- | ---- | ------------------------------------------------------------ | | ----- | ------------------------------------- | ---- | ---------------------------------------- |
| value | string \| [FunctionKey](#functionkey) | Yes | Character key (which can be entered through the keyboard) or [function key](#functionkey).<br>| | value | string \| [FunctionKey](#functionkey) | Yes | Character key (which can be entered through the keyboard) or [function key](#functionkey).<br>|
| keys | Array<[ModifierKey](#modifierkey)> | Yes | Modifier keys.<br> | | keys | Array<[ModifierKey](#modifierkey)> | Yes | Modifier keys.<br> |
## ModifierKey ## ModifierKey
| Name | Description | | Name | Description |
| ----- | ------------------- | | ----- | ------------ |
| CTRL | Ctrl key on the keyboard. | | CTRL | Ctrl key on the keyboard. |
| SHIFT | Shift key on the keyboard.| | SHIFT | Shift key on the keyboard.|
| ALT | Alt key on the keyboard. | | ALT | Alt key on the keyboard. |
## FunctionKey ## FunctionKey
| Name| Description | | Name | Description |
| ---- | --------------------- | | ---- | ------------ |
| ESC | Esc key on the keyboard.| | ESC | Esc key on the keyboard.|
| F1 | F1 key on the keyboard. | | F1 | F1 key on the keyboard. |
| F2 | F2 key on the keyboard. | | F2 | F2 key on the keyboard. |
...@@ -45,35 +45,35 @@ keyboardShortcut(value: string | [FunctionKey], keys: Array<[ModifierKey]>) ...@@ -45,35 +45,35 @@ keyboardShortcut(value: string | [FunctionKey], keys: Array<[ModifierKey]>)
## Precautions for Using Keyboard Shortcuts ## Precautions for Using Keyboard Shortcuts
| Scenario | Processing Logic | Example | | Scenario | Processing Logic | Example |
| ------------------------------------------------------------ | -------------------------------------------------------- | ------------------------------------------------------------ | | ---------------------------------------- | ---------------------------------- | ---------------------------------------- |
| All components that support the **onClick** event | Custom keyboard shortcuts are supported. | – | | All components that support the **onClick** event | Custom keyboard shortcuts are supported. | – |
| Requirements for custom keyboard shortcuts | A custom keyboard shortcut consists of one or more modifier keys (**Ctrl**, **Shift**, **Alt**, or any combination thereof) and a character key or function key.| Button('button1').keyboardShortcut('a',[ModifierKey.CTRL]) | | Requirements for custom keyboard shortcuts | A custom keyboard shortcut consists of one or more modifier keys (**Ctrl**, **Shift**, **Alt**, or any combination thereof) and a character key or function key.| Button('button1').keyboardShortcut('a',[ModifierKey.CTRL]) |
| Setting one custom keyboard shortcut for multiple components | Only the first component in the component tree responds to the custom keyboard shortcut. | Button('button1').keyboardShortcut('a',[ModifierKey.CTRL])<br>Button('button2').keyboardShortcut('a',[ModifierKey.CTRL]) | | Setting one custom keyboard shortcut for multiple components | Only the first component in the component tree responds to the custom keyboard shortcut. | Button('button1').keyboardShortcut('a',[ModifierKey.CTRL])<br>Button('button2').keyboardShortcut('a',[ModifierKey.CTRL]) |
| When the component is focused or not | The component responds to the custom keyboard shortcut as long as the window is focused. | – | | When the component is focused or not | The component responds to the custom keyboard shortcut as long as the window is focused. | – |
| When a single keyboard shortcut is set, it can be canceled by setting the **value**, **keys**, or both of them to null in the **keyboardShortcut** API.<br>When multiple keyboard shortcuts are set, they cannot be canceled.| Canceling the custom keyboard shortcut settings | Button('button1').keyboardShortcut('',[ModifierKey.CTRL])<br>Button('button2').keyboardShortcut('a',[l])<br>Button('button3').keyboardShortcut('',[]) | | When a single keyboard shortcut is set, it can be canceled by setting the **value**, **keys**, or both of them to null in the **keyboardShortcut** API.<br>When multiple keyboard shortcuts are set, they cannot be canceled.| Canceling the custom keyboard shortcut settings | Button('button1').keyboardShortcut('',[ModifierKey.CTRL])<br>Button('button2').keyboardShortcut('a',[l])<br>Button('button3').keyboardShortcut('',[]) |
| The independent pipeline sub-window and main window coexist | The focused window responds to the keyboard shortcut. | – | | The independent pipeline sub-window and main window coexist | The focused window responds to the keyboard shortcut. | – |
| Ctrl, Shift, or Alt key in the **keys** parameter of the **keyboardShortcut** API | Both the keys on the left or right sides of the keyboard work. | Button('button1').keyboardShortcut('a',[ModifierKey.CTRL, ModifierKey.ALT]) | | Ctrl, Shift, or Alt key in the **keys** parameter of the **keyboardShortcut** API| Both the keys on the left or right sides of the keyboard work. | Button('button1').keyboardShortcut('a',[ModifierKey.CTRL, ModifierKey.ALT]) |
| Character key in the **value** parameter of the **keyboardShortcut** API | The response is case-insensitive. | Button('button1').keyboardShortcut('a',[ModifierKey.CTRL])<br>Button('button2').keyboardShortcut('A',[ModifierKey.CTRL]) | | Character key in the **value** parameter of the **keyboardShortcut** API | The response is case-insensitive. | Button('button1').keyboardShortcut('a',[ModifierKey.CTRL])<br>Button('button2').keyboardShortcut('A',[ModifierKey.CTRL]) |
| Response to keyboard shortcuts | The component responds continuously to the keyboard shortcut when all the set keys are pressed. | – | | Response to keyboard shortcuts | The component responds continuously to the keyboard shortcut when all the set keys are pressed. | – |
| Hidden component<br> | The keyboard shortcut also works. | – | | Hidden component<br> | The keyboard shortcut also works. | – |
| Components in the disable state | The keyboard shortcut does not work. | – | | Components in the disable state | The keyboard shortcut does not work. | – |
| 1. The keyboard shortcut is the same as an existing one (including the system-defined ones).<br>2. The **value** parameter contains multiple character keys.<br>3. The **key** parameter has a duplicate modifier key.| In these cases, the keyboard shortcut is not added, and the previously added keyboard shortcuts still work. | Button('button1').keyboardShortcut('c',[ModifierKey.CTRL])<br>Button('button2').keyboardShortcut('ab',[ModifierKey.CTRL])<br>Button('button3').keyboardShortcut('ab',[ModifierKey.CTRL,ModifierKey.CTRL]) | | 1. The keyboard shortcut is the same as an existing one (including the system-defined ones).<br>2. The **value** parameter contains multiple character keys.<br>3. The **key** parameter has a duplicate modifier key.| In these cases, the keyboard shortcut is not added, and the previously added keyboard shortcuts still work. | Button('button1').keyboardShortcut('c',[ModifierKey.CTRL])<br>Button('button2').keyboardShortcut('ab',[ModifierKey.CTRL])<br>Button('button3').keyboardShortcut('ab',[ModifierKey.CTRL,ModifierKey.CTRL]) |
## System-defined Keyboard Shortcuts ## System-defined Keyboard Shortcuts
| Keyboard Shortcut | Component | | Keyboard Shortcut | Component |
| -------------- | ------------------------------------------------------------ | | -------------- | ---------------------------------------- |
| Ctrl + C | [Image](ts-basic-components-image.md), [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Ctrl + C | [Image](ts-basic-components-image.md), [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
| Ctrl+ A | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Ctrl+ A | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
| Ctrl+ V | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Ctrl+ V | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
| Ctrl+ X | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Ctrl+ X | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
| Shift + arrow keys| [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Shift + arrow keys | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
| Ctrl+ Shift+ Z | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Ctrl+ Shift+ Z | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
| Ctrl+ Z | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Ctrl+ Z | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
| Ctrl+ Y | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Ctrl+ Y | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
| Arrow keys and Enter key| [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Arrow keys and Enter key | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
| Tab key | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)| | Tab key | [TextInput](ts-basic-components-textinput.md), [TextArea](ts-basic-components-textarea.md)|
## Example ## Example
......
...@@ -12,7 +12,7 @@ Touchscreen events are events triggered when a finger or stylus is placed on, mo ...@@ -12,7 +12,7 @@ Touchscreen events are events triggered when a finger or stylus is placed on, mo
## Click Event ## Click Event
A click event is triggered when a complete press and lift action performed by using a finger or a stylus. When a click event occurs, the following callback is triggered: A click event is triggered when a complete press and lift action is performed by using a finger or a stylus. When a click event occurs, the following callback is triggered:
```ts ```ts
onClick(event: (event?: ClickEvent) => void) onClick(event: (event?: ClickEvent) => void)
......
...@@ -89,11 +89,7 @@ You can draw custom graphics on the canvas in any of the following ways: ...@@ -89,11 +89,7 @@ You can draw custom graphics on the canvas in any of the following ways:
import lottie from '@ohos/lottie' import lottie from '@ohos/lottie'
``` ```
For details about the APIs, see [Lottie](../reference/arkui-ts/ts-components-canvas-lottie.md). For details about the APIs, see [Lottie](https://gitee.com/openharmony-tpc/lottieETS).
>**NOTE**
>
>Before using Lottie for the first time, run the **ohpm install \@ohos/lottieETS** command in the Terminal window to download Lottie.
## Initializing the Canvas Component ## Initializing the Canvas Component
...@@ -117,7 +113,7 @@ Canvas(this.context) ...@@ -117,7 +113,7 @@ Canvas(this.context)
## Canvas Component Drawing Modes ## Canvas Component Drawing Modes
Two modes are available for drawing with the **Canvas** component: Two modes are available for drawing with the **Canvas** component:
- After the **onReady()** callback of the **Canvas** component is invoked, use the **CanvasRenderingContext2D** and **OffscreenCanvasRenderingContext2D** objects to call related APIs for drawing. - After the **onReady()** callback of the **Canvas** component is invoked, use the **CanvasRenderingContext2D** and **OffscreenCanvasRenderingContext2D** objects to call related APIs for drawing.
...@@ -159,9 +155,8 @@ Two modes are available for drawing with the **Canvas** component: ...@@ -159,9 +155,8 @@ Two modes are available for drawing with the **Canvas** component:
- Draw a basic shape. - Draw a basic shape.
You can draw a basic shape by calling APIs such as [arc](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#arc), [ellipse](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#ellipse), and [rect](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#rect).
You can draw a basic shape by calling APIs such as [arc](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#arc), [ellipse](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#ellipse), and [rect](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#rect).
```ts ```ts
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
...@@ -183,9 +178,9 @@ You can draw a basic shape by calling APIs such as [arc](../reference/arkui-ts/t ...@@ -183,9 +178,9 @@ You can draw a basic shape by calling APIs such as [arc](../reference/arkui-ts/t
}) })
``` ```
![2023022794521(1)](figures/2023022794521(1).jpg) ![2023022794521(1)](figures/2023022794521(1).jpg)
- Draw text. - Draw text.
You can use APIs such as [fillText](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#filltext) and [strokeText](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#stroketext) to draw text. You can use APIs such as [fillText](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#filltext) and [strokeText](../reference/arkui-ts/ts-canvasrenderingcontext2d.md#stroketext) to draw text.
...@@ -345,4 +340,3 @@ You can draw a basic shape by calling APIs such as [arc](../reference/arkui-ts/t ...@@ -345,4 +340,3 @@ You can draw a basic shape by calling APIs such as [arc](../reference/arkui-ts/t
``` ```
![2023032422159](figures/2023032422159.jpg) ![2023032422159](figures/2023032422159.jpg)
# Event Overview # Interaction Event Overview
Interaction events are classified into touchscreen events, keyboard and mouse events, and focus events based on trigger types. Interaction events are classified based on trigger types into touchscreen events, keyboard and mouse events, and focus events.
- [Touchscreen event](arkts-common-events-touch-screen-event.md): single-finger or single-stroke operation performed by a finger or stylus on the touchscreen. - [Touchscreen event](arkts-common-events-touch-screen-event.md): an event triggered by the operation performed a finger or stylus on the touchscreen.
- [Keyboard and mouse event](arkts-common-events-device-input-event.md): includes operation events of the peripheral mouse or touchpad and key events of the peripheral keyboard. - [Keyboard and mouse event](arkts-common-events-device-input-event.md): an event triggered by an operation performed on a peripheral mouse, touchpad, or keyboard.
- The mouse event refers to an event responded to when an operation is performed with a peripheral mouse/touchpad. - The mouse event refers to an event responded to when an operation is performed with a peripheral mouse or touchpad.
- The key event refer to an event responded to when an operation is performed with a peripheral keyboard. - The keyboard event refera to an event responded to when an operation is performed with a peripheral keyboard.
- [Focus event](arkts-common-events-focus-event.md): controls the focusability and response events of the component in the preceding ways. - [Focus event](arkts-common-events-focus-event.md): an event triggered when a component receives or loses focus.
The gesture event includes the gesture binding method and the bound gesture. The bound gesture may be classified into two types: a single gesture and a combined gesture, and is distinguished according to complexity of the gesture. The gesture event includes the gesture binding method and the bound gesture – a single or combined gesture.
- [Gesture binding](arkts-gesture-events-binding.md): binds a single gesture or a combination of gestures to a component and declares the response priority of the bound gesture. - [Gesture binding method](arkts-gesture-events-binding.md): a method that binds a single or combined gesture to a component and declares the response priority of the bound gesture.
- [Single gesture](arkts-gesture-events-single-gesture.md): basic unit of a gesture, which is a part of all complex gestures. - [Single gesture](arkts-gesture-events-single-gesture.md): basic unit of gestures, which is a part of all complex gestures.
- [Combined gesture](arkts-gesture-events-combined-gestures.md): a combination of multiple single gestures. Multiple single gestures can be combined into a combined gesture according to a declared type and a certain rule, and the combined gesture can be used. - [Combined gesture](arkts-gesture-events-combined-gestures.md): a combination of single gestures brought together according to a declared type and a certain rule.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册