diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md index 0a0365a9d3ff3672f346425bab7317a8a83e2694..58df52babe0d9feea64e23bba0271c8a5ccf60ec 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md @@ -1,12 +1,10 @@ # TextPicker +The **TextPicker** component allows users to scroll to select text. -The **\** component allows users to select text from a list of options. - - -> **NOTE** +> **NOTE** > -> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. ## Required Permissions @@ -21,35 +19,34 @@ Not supported ## APIs -TextPicker(value: {range: string[] | Resource, value?: string, selected?: number}) +TextPicker(options: {range: string[]|Resource, selected?: number, value?: string}) Creates a text picker based on the selection range specified by **range**. - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | range | string[]\| [Resource](../../ui/ts-types.md) | Yes | - | Data selection range of the picker. | - | value | string | No | - | Search text. | - | selected | number | No | Index of the first item | Index of the selected item in the array. | + | range | string[] \| [Resource](../../ui/ts-types.md#resource-type)| Yes| - | Data selection range of the picker.| + | selected | number | No| 0 | Index of the selected item in the range. | + | value | string | No| Value of the first item| Value of the selected item. The priority of this parameter is lower than that of **selected**.| ## Attributes -| Name | Type | Default Value | Description | +| Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| defaultPickerItemHeight | Length | - | Default height of an item in the picker. | +| defaultPickerItemHeight | Length | - | Default height of an item in the picker.| ## Events -| Name | Description | +| Name| Description| | -------- | -------- | -| onChange(callback: (value: string, index: number) => void) | Triggered when an item in the picker is selected.
- **value**: text of the selected item.
- **index**: index of the selected item. | +| onChange(callback: (value: string, index: number) => void) | Triggered when an item in the picker is selected.
- **value**: value of the selected item.
- **index**: index of the selected item.| ## Example - ```ts // xxx.ets @Entry diff --git a/en/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md b/en/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md index 03ff3185148fd491cf5ed04c84a6fb1cd47c6d5e..7f22b7a2e6d66f4bb99bc57dabdeb32109885725 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md @@ -1,10 +1,12 @@ # Text Picker Dialog Box -> **NOTE**
-> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - You can display a text picker in a dialog box to allow users to select text from the given range. +> **NOTE** +> +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + ## Required Permissions None @@ -16,24 +18,26 @@ show(options: TextPickerDialogOptions) Shows a text picker in the given settings. - TextPickerDialogOptions - | Name | Type | Mandatory | Default Value | Description | + | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | range | string[] | Yes | - | Data selection range of the picker. | - | selected | number | No | First element | Index value of the selected item in the range. | - | defaultPickerItemHeight | number | No | - | Height of the default selected item in the picker. | - | onAccept | (value: TextPickerResult) => void | No | - | Callback invoked when the OK button in the dialog box is clicked. | - | onCancel | () => void | No | - | Triggered when the Cancel button in the dialog box is clicked. | - | onChange | (value: TextPickerResult) => void | No | - | Callback invoked when the selected item in the picker changes. | + | range | string[] | Yes| - | Data selection range of the picker.| + | selected | number | No| 0 | Index of the selected item in the range.| + | value | string | No | - | Value of the selected item. This parameter does not take effect when the **selected** parameter is set. If the value is not within the range, the first item in the range is used instead.| + | defaultPickerItemHeight | number | No| - | Default height of an item in the picker.| + | onAccept | (value: TextPickerResult) => void | No| - | Triggered when the OK button in the dialog box is clicked.| + | onCancel | () => void | No| - | Triggered when the Cancel button in the dialog box is clicked.| + | onChange | (value: TextPickerResult) => void | No| - | Triggered when the selected item in the picker changes.| - TextPickerResult - | Name | Type | Description | + | Name| Type| Description| | -------- | -------- | -------- | - | value | string | Text of the selected item. | - | index | number | Index value of the selected item in the range. | + | value | string | Value of the selected item.| + | index | number | Index of the selected item in the range.| ## Example -``` +```ts +// xxx.ets @Entry @Component struct TextPickerDialogExample {