未验证 提交 e3852d5c 编写于 作者: O openharmony_ci 提交者: Gitee

!5565 翻译完成 4971:TextInput、TextArea、Search支持设置copyOption

Merge pull request !5565 from ester.zhou/TR-4971
......@@ -256,7 +256,7 @@ Specifies the focused status attribute of the target component.
**Example**
```js
let by = BY.enabled(true) // Use the static constructor BY to create a By object and specify the focused status attribute of the target component.
let by = BY.focused(true) // Use the static constructor BY to create a By object and specify the focused status attribute of the target component.
```
### By.selected
......
......@@ -35,6 +35,7 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll
| placeholderColor | [ResourceColor](../../ui/ts-types.md) | - | Placeholder text color. |
| placeholderFont | [Font](../../ui/ts-types.md) | - | Placeholder text style. |
| textFont | [Font](../../ui/ts-types.md) | - | Text font for the search text box. |
| copyOption<sup>9+</sup> | boolean\|[CopyOption](ts-basic-components-text.md) | true | Whether copy and paste is allowed. |
## Events
......@@ -56,7 +57,7 @@ controller: SearchController = new SearchController()
```
#### caretPosition
creatPosition(value: number): void
caretPosition(value: number): void
Sets the position of the caret.
......@@ -64,13 +65,14 @@ Sets the position of the caret.
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------------------- |
| value | number | Yes | - | Length from the start of the character string to the position where the caret is located. |
| value | number | Yes | - | Length from the start of the text string to the position where the caret is located. |
## Example
```
```ts
// xxx.ets
@Entry
@Component
struct SearchExample {
......
......@@ -5,7 +5,7 @@
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;TextArea&gt;** component provides multi-line text input.
The **\<TextArea>** component provides multi-line text input.
## Required Permissions
......@@ -37,9 +37,10 @@ In addition to universal attributes, the following attributes are supported.
| ------------------------ | ---------------------------------------- | ------------- | ---------------------------------------- |
| placeholderColor | Color | - | Placeholder text color. |
| placeholderFont | {<br/>size?: number,<br/>weight?:number \| [FontWeight](ts-universal-attributes-text-style.md),<br/>family?: string,<br/>style?: [FontStyle](ts-universal-attributes-text-style.md)<br/>} | - | Placeholder text style.<br/>- **size**: font size. If the value is of the number type, the unit fp is used.<br/>- **weight**: font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight.<br/>- **family**: font family. Use commas (,) to separate multiple fonts, for example, **'Arial, sans-serif'**. The priority of the fonts is the sequence in which they are placed.<br/>- **style**: font style. |
| textAlign | TextAlign | Start | Sets the text horizontal alignment mode. |
| caretColor | Color | - | Sets the color of the cursor in the text box. |
| inputFilter<sup>8+</sup> | {<br/>value: [ResourceStr](../../ui/ts-types.md),<br/>error?: (value: string)<br/>} | - | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are ignored. The specified regular expression can match single characters, but not strings. Example: ^(? =.\*\d)(? =.\*[a-z])(? =.\*[A-Z]).{8,10}$. Strong passwords containing 8 to 10 characters cannot be filtered.<br/>- **value**: indicates the regular expression to set.<br/>- **error**: returns the ignored content when regular expression matching fails. |
| textAlign | TextAlign | Start | Text horizontal alignment mode. |
| caretColor | Color | - | Color of the caret in the text box. |
| inputFilter<sup>8+</sup> | {<br/>value: [ResourceStr](../../ui/ts-types.md)<sup>8+</sup>,<br/>error?: (value:&nbsp;string)<br/>} | - | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are ignored. The specified regular expression can match single characters, but not strings. Example: ^(? =.\*\d)(? =.\*[a-z])(? =.\*[A-Z]).{8,10}$. Strong passwords containing 8 to 10 characters cannot be filtered.<br/>- **value**: indicates the regular expression to set.<br/>- **error**: returns the ignored content when regular expression matching fails. |
| copyOption<sup>9+</sup> | boolean\|[CopyOption](ts-basic-components-text.md) | true | Whether copy and paste is allowed. |
- TextAlign enums
| Name | Description |
......@@ -76,9 +77,9 @@ caretPosition(value: number): void
Sets the position of the caret.
- Parameters
| Name | Type | Mandatory | Default Value | Description |
| ----- | ------ | --------- | ------------- | ---------------------------------------- |
| value | number | Yes | - | Length from the start of the string to the position where the input cursor is located. |
| Name | Type | Mandatory | Default Value | Description |
| ----- | ------ | --------- | ------------- | ------------------------------------------------------------ |
| value | number | Yes | - | Length from the start of the text string to the position where the caret is located. |
## Example
......@@ -87,7 +88,8 @@ Sets the position of the caret.
### Multi-line Text Input
```
```ts
// xxx.ets
@Entry
@Component
struct TextAreaExample1 {
......@@ -120,10 +122,10 @@ struct TextAreaExample1 {
![en-us_image_0000001256858399](figures/en-us_image_0000001256858399.gif)
### Setting the Input Cursor
### Setting the Caret
```
```ts
// xxx.ets
@Entry
@Component
struct TextAreaExample2 {
......
......@@ -4,7 +4,7 @@
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;TextInput&gt;** component provides single-line text input.
The **\<TextInput>** component provides single-line text input.
## Required Permissions
......@@ -41,6 +41,7 @@ In addition to universal attributes, the following attributes are supported.
| caretColor | Color | - | Color of the caret (also known as the text insertion cursor). |
| maxLength<sup>8+</sup> | number | - | Maximum number of characters in the text input. |
| inputFilter<sup>8+</sup> | {<br/>value: [ResourceStr](../../ui/ts-types.md)<sup>8+</sup>,<br/>error?: (value: string)<br/>} | - | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are ignored. The specified regular expression can match single characters, but not strings. Example: ^(? =.\*\d)(? =.\*[a-z])(? =.\*[A-Z]).{8,10}$. Strong passwords containing 8 to 10 characters cannot be filtered.<br/>- **value**: regular expression to set.<br/>- **error**: error message containing the ignored content returned when regular expression matching fails. |
| copyOption<sup>9+</sup> | boolean\|[CopyOption](ts-basic-components-text.md) | true | Whether copy and paste is allowed. |
- EnterKeyType enums
| Name | Description |
......@@ -85,16 +86,16 @@ controller: TextInputController = new TextInputController()
```
#### caretPosition
### caretPosition
caretPosition(value: number): void
Sets the cursor in a specified position.
Sets the position of the caret.
- Parameters
| Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
| value | number | Yes | - | Position of the input cursor.<br/>**value**: length from the start of the string to the position where the input cursor is located. |
| value | number | Yes | - | Length from the start of the text string to the position where the caret is located. |
......@@ -103,8 +104,8 @@ Sets the cursor in a specified position.
### Single-line Text Input
```
```ts
// xxx.ets
@Entry
@Component
struct TextInputExample1 {
......@@ -136,10 +137,10 @@ struct TextInputExample1 {
![en-us_image_0000001212378402](figures/en-us_image_0000001212378402.gif)
### Setting the Input Cursor
### Setting the Caret
```
```ts
// xxx.ets
@Entry
@Component
struct TextInputExample2 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册