/* * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file * @kit ArkUI */ /*** if arkts 1.2 */ import { TextContentControllerBase, SelectionOptions,Callback,CommonMethod,Optional,TextDecorationOptions, Bindable } from './common'; import { CustomBuilder } from './builder'; import { ResourceStr,Length,ResourceColor ,Dimension,Font} from './units'; import { CaretStyle, EditableTextOnChangeCallback, InsertValue, DeleteValue, EditMenuOptions,KeyboardAppearance,EditableTextChangeValue,AutoCapitalizationMode } from './textCommon'; import { EnterKeyType, OnTextSelectionChangeCallback, OnContentScrollCallback, OnPasteCallback, SubmitEvent } from './textInput'; import { CopyOptions,TextAlign } from './enums'; import { KeyboardOptions } from './richEditor'; import { Resource } from '../../global/resource'; import { SymbolGlyphModifier } from '../SymbolGlyphModifier'; /*** endif */ /** * Provides the method of switching the cursor position. * * @extends TextContentControllerBase * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 8 */ /** * Provides the method of switching the cursor position. * * @extends TextContentControllerBase * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * Provides the method of switching the cursor position. * * @extends TextContentControllerBase * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ declare class SearchController extends TextContentControllerBase { /** * constructor. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 8 */ /** * constructor. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * constructor. * A constructor used to create a SearchController object. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ constructor(); /** * Called when the position of the insertion cursor is set. * * @param { number } value * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 8 */ /** * Called when the position of the insertion cursor is set. * * @param { number } value * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * Called when the position of the insertion cursor is set. * * @param { number } value - Length from the start of the character string to the position where the caret is located. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ caretPosition(value: number): void; /** * Exit edit state. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * Exit edit state. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ stopEditing(): void; /** * Text selection is achieved by specifying the start and end positions of the text. * *
NOTE:
*
If selectionStart or selectionEnd is set to undefined, the value 0 will be used.
*
If selectionMenuHidden is set to true or a 2-in-1 device is used,
* calling setTextSelection does not display the context menu even when options is set to MenuPolicy.SHOW.
*
If the selected text contains an emoji, the emoji is selected when its start position is within the text selection range.
*
Sets the text selection range and highlights the selected text when the component is focused.
*
This API works only when the value of selectionStart is less than that of selectionEnd.
*
NOTE:
*
Since API version 10, this parameter supports two-way binding through $$.
*
Since API version 18, this parameter supports two-way binding through !!.
*
NOTE:
*
The icon data source can be a local or online image.
*
NOTE:
*
It cannot be set in percentage.
*
NOTE:
*
It cannot be set in percentage.
*
NOTE:
*
true: The search button is disabled when there is no text input.
*
false: The search button remains enabled regardless of the text input.
*
NOTE:
*
Clicking the search button triggers both onSubmit and onClick callbacks.
*
The default font size on wearable devices is 18 fp.
*
NOTE:
*
Universal text attributes fontSize, fontStyle, fontWeight, and fontFamily are set in the textFont attribute.
*
NOTE:
*
The default icon size on wearable devices is 16 vp.
*
Default value in light mode:
*
* {
* size: '16vp',
* color: '#99182431',
* src: ' '
* }
*
*
Default value in dark mode:
*
* {
* size: '16vp',
* color: '#99ffffff',
* src: ' '
* }
*
*
NOTE:
*
The default icon size on wearable devices is 18 vp.
*
When style is set to CancelButtonStyle.CONSTANT, the Cancel button is always displayed.
*
Default value:
*
* {
* style: CancelButtonStyle.INPUT,
* icon: {
* size: '16vp',
* color: '#99ffffff',
* src: ' '
* }
* }
*
*
NOTE:
*
Only inputs that comply with the regular expression can be displayed.
*
Other inputs are filtered out.
*
The specified regular expression can match single characters, but not strings.
*
If inputFilter is set and the entered characters are not null,
* the filtering effect attached to the text box type (specified through the type attribute) does not take effect.
*
NOTE:
*
If the opacity is not set, a 20% opacity will be used.
*
NOTE:
*
Since API version 12, this API can be used to set the text handle color, which is the same as the caret color.
*
Default value:
*
* {
* width: '1.5vp',
* color: '#007DFF'
* }
*
*
NOTE:
*
The 'HarmonyOS Sans' font and registered custom fonts are supported.
*
The default font size on wearable devices is 18 px.
*
NOTE:
*
Currently, only the default font family is supported.
*
The default font size on wearable devices is 18 fp.
*
NOTE:
*
In this callback, if cursor operations are performed,
* developers need to adjust the cursor logic based on the previewText parameter to ensure it works seamlessly within the preview display scenario.
*
NOTE:
*
If this attribute is set to CopyOptions.None, the text can only be pasted;
* all other actions, such as copying, cutting, and sharing, are disabled.
*
Dragging is not allowed when CopyOptions.None is set.
*
NOTE:
*
By default, there is no maximum number of characters.
*
When the maximum number is reached, no more characters can be entered.
*
NOTE:
*
By default, there is no maximum number of characters.
*
When the maximum number is reached, no more characters can be entered.
*
NOTE:
*
Currently, the following alignment modes are supported: Start, Center, and End.
*
NOTE:
*
Since API version 10, the Search component brings up the keyboard by default when it obtains focus.
*
NOTE:
*
true: Tapping, long-pressing, double-tapping, triple-tapping,
* or right-clicking the text box will not trigger the system text selection menu.
*
false: Tapping, long-pressing, double-tapping, triple-tapping,
* or right-clicking the text box will trigger the system text selection menu.
*
NOTE:
*
For the string type, numeric string values with optional units, for example, "10" or "10fp", are supported.
*
For the setting to take effect, this attribute must be used together with maxFontSize or layout constraint settings.
*
When the adaptive font size is used, the fontSize settings do not take effect.
*
NOTE:
*
For the string type, numeric string values with optional units, for example, "10" or "10fp", are supported.
*
For the setting to take effect, this attribute must be used together with minFontSize or layout constraint settings.
*
When the adaptive font size is used, the fontSize settings do not take effect.
*
NOTE:
*
The undefined type is supported.
*
A value less than 0 is handled as 0.
*
A value greater than 1 is handled as 1.
*
Abnormal values are ineffective by default.
*
NOTE:
*
The undefined type is supported.
*
A value less than 0 is handled as 0.
*
A value greater than 1 is handled as 1.
*
Abnormal values are ineffective by default.
*
NOTE:
*
The undefined type is supported.
*
A value less than 1 is handled as 1.
*
Abnormal values are ineffective by default.
*
NOTE:
*
The undefined type is supported.
*
A value less than 1 is handled as 1.
*
Abnormal values are ineffective by default.
*
NOTE:
*
When a custom keyboard is set, activating the text box opens the specified custom component,
* instead of the system input method.
*
The custom keyboard's height can be set through the height attribute of the custom component's root node,
* and its width is fixed at the default value.
*
The custom keyboard is presented by overlaying the original screen.
*
It is not compressed or lifted if avoid mode is not enabled or avoidance is not needed for the text box.
*
The custom keyboard cannot obtain the focus, but it blocks gesture events.
*
By default, the custom keyboard is closed when the input component loses the focus.
*
You can also use the stopEditing API to close the keyboard.
*
When a custom keyboard is set, the text box does not support camera input, even when the device supports.
*
When setting a custom keyboard, you can bind the onKeyPrelme event to prevent input from the physical keyboard.
*
NOTE:
*
If the value specified is a percentage or 0, the default value is used.
*
For the string type, numeric string values with optional units, for example, "10" or "10fp", are supported.
*
If the value specified is a negative value, the text is compressed.
*
A negative value too small may result in the text being compressed to 0 and no content being displayed.
*
NOTE:
*
If the value is less than or equal to 0, the line height is not limited and the font size is adaptive.
*
If the value is of the number type, the unit fp is used.
*
NOTE:
*
It returns true if the text is inserted; returns false otherwise.
*
This callback is not triggered for pre-edit or candidate word operations.
*
It is available only for system input methods.
*
NOTE:
*
It is available only for system input methods.
*
NOTE:
*
It returns true if the text is deleted; returns false otherwise.
*
This callback is not invoked for text preview.
*
It is available only for system input methods.
*
NOTE:
*
It is available only for system input methods.
*
NOTE:
*
Preview text is in a temporary state and does not support text interception.
*
As such, it does not trigger onWillInsert, onDidInsert, onWillDelete, or onDidDelete callbacks.
*
NOTE:
*
To enable haptic feedback,
* you must declare the ohos.permission.VIBRATE permission under requestPermissions in the module.json5 file of the project.
*
* "requestPermissions": [
* {
* "name": "ohos.permission.VIBRATE",
* }
* ]
*
*
NOTE:
*
This callback is triggered after onWillInsert and onWillDelete, but before onDidInsert and onDidDelete.
*