/* * Copyright (c) 2021-2023 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. */ #include "frameworks/bridge/declarative_frontend/jsview/js_textinput.h" #include #include #include #include #include "core/common/container.h" #include "frameworks/bridge/common/utils/utils.h" #include "frameworks/bridge/declarative_frontend/engine/functions/js_clipboard_function.h" #include "frameworks/bridge/declarative_frontend/engine/functions/js_function.h" #include "frameworks/bridge/declarative_frontend/jsview/js_text_editable_controller.h" #include "frameworks/bridge/declarative_frontend/jsview/js_textfield.h" #include "frameworks/bridge/declarative_frontend/jsview/js_view_common_def.h" #include "frameworks/bridge/declarative_frontend/view_stack_processor.h" #include "frameworks/core/common/ime/text_input_action.h" #include "frameworks/core/common/ime/text_input_type.h" #include "frameworks/core/components/text_field/text_field_component.h" #include "frameworks/core/components/text_field/textfield_theme.h" namespace OHOS::Ace::Framework { void JSTextInput::JSBind(BindingTarget globalObj) { JSClass::Declare("TextInput"); MethodOptions opt = MethodOptions::NONE; JSClass::StaticMethod("create", &JSTextInput::Create, opt); JSClass::StaticMethod("type", &JSTextField::SetType); JSClass::StaticMethod("placeholderColor", &JSTextField::SetPlaceholderColor); JSClass::StaticMethod("placeholderFont", &JSTextField::SetPlaceholderFont); JSClass::StaticMethod("backgroundColor", &JSTextField::SetBackgroundColor); JSClass::StaticMethod("enterKeyType", &JSTextField::SetEnterKeyType); JSClass::StaticMethod("caretColor", &JSTextField::SetCaretColor); JSClass::StaticMethod("caretPosition", &JSTextField::SetCaretPosition); JSClass::StaticMethod("selectedBackgroundColor", &JSTextField::SetSelectedBackgroundColor); JSClass::StaticMethod("caretStyle", &JSTextField::SetCaretStyle); JSClass::StaticMethod("maxLength", &JSTextField::SetMaxLength); JSClass::StaticMethod("width", &JSTextField::JsWidth); JSClass::StaticMethod("height", &JSTextField::JsHeight); JSClass::StaticMethod("padding", &JSTextField::JsPadding); JSClass::StaticMethod("border", &JSTextField::JsBorder); JSClass::StaticMethod("borderWidth", &JSTextField::JsBorderWidth); JSClass::StaticMethod("borderColor", &JSTextField::JsBorderColor); JSClass::StaticMethod("borderStyle", &JSTextField::JsBorderStyle); JSClass::StaticMethod("borderRadius", &JSTextField::JsBorderRadius); JSClass::StaticMethod("fontSize", &JSTextField::SetFontSize); JSClass::StaticMethod("fontColor", &JSTextField::SetTextColor); JSClass::StaticMethod("fontWeight", &JSTextField::SetFontWeight); JSClass::StaticMethod("fontStyle", &JSTextField::SetFontStyle); JSClass::StaticMethod("fontFamily", &JSTextField::SetFontFamily); JSClass::StaticMethod("inputFilter", &JSTextField::SetInputFilter); JSClass::StaticMethod("showPasswordIcon", &JSTextField::SetShowPasswordIcon); JSClass::StaticMethod("textAlign", &JSTextField::SetTextAlign); JSClass::StaticMethod("style", &JSTextField::SetInputStyle); JSClass::StaticMethod("hoverEffect", &JSTextField::JsHoverEffect); JSClass::StaticMethod("copyOption", &JSTextField::SetCopyOption); JSClass::StaticMethod("textMenuOptions", &JSTextField::JsMenuOptionsExtension); JSClass::StaticMethod("foregroundColor", &JSTextField::SetForegroundColor); JSClass::StaticMethod("showUnit", &JSTextField::SetShowUnit); JSClass::StaticMethod("showError", &JSTextField::SetShowError); JSClass::StaticMethod("barState", &JSTextField::SetBarState); JSClass::StaticMethod("maxLines", &JSTextField::SetMaxLines); // API7 onEditChanged deprecated JSClass::StaticMethod("onEditChanged", &JSTextField::SetOnEditChanged); JSClass::StaticMethod("onEditChange", &JSTextField::SetOnEditChanged); JSClass::StaticMethod("onSubmit", &JSTextField::SetOnSubmit); JSClass::StaticMethod("onChange", &JSTextField::SetOnChange); JSClass::StaticMethod("onTextSelectionChange", &JSTextField::SetOnTextSelectionChange); JSClass::StaticMethod("onContentScroll", &JSTextField::SetOnContentScroll); JSClass::StaticMethod("onCopy", &JSTextField::SetOnCopy); JSClass::StaticMethod("onCut", &JSTextField::SetOnCut); JSClass::StaticMethod("onPaste", &JSTextField::SetOnPaste); JSClass::StaticMethod("onClick", &JSTextField::SetOnClick); JSClass::StaticMethod("requestKeyboardOnFocus", &JSTextField::SetEnableKeyboardOnFocus); JSClass::StaticMethod("onTouch", &JSInteractableView::JsOnTouch); JSClass::StaticMethod("onHover", &JSInteractableView::JsOnHover); JSClass::StaticMethod("onKeyEvent", &JSInteractableView::JsOnKey); JSClass::StaticMethod("onDeleteEvent", &JSInteractableView::JsOnDelete); JSClass::StaticMethod("onAppear", &JSInteractableView::JsOnAppear); JSClass::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear); JSClass::StaticMethod("passwordIcon", &JSTextField::SetPasswordIcon); JSClass::StaticMethod("showUnderline", &JSTextField::SetShowUnderline); JSClass::StaticMethod("enableKeyboardOnFocus", &JSTextField::SetEnableKeyboardOnFocus); JSClass::StaticMethod("selectionMenuHidden", &JSTextField::SetSelectionMenuHidden); JSClass::StaticMethod("customKeyboard", &JSTextField::SetCustomKeyboard); JSClass::StaticMethod("passwordRules", &JSTextField::SetPasswordRules); JSClass::StaticMethod("enableAutoFill", &JSTextField::SetEnableAutoFill); JSClass::StaticMethod("cancelButton", &JSTextField::SetCancelButton); JSClass::StaticMethod("selectAll", &JSTextField::SetSelectAllValue); JSClass::StaticMethod("showCounter", &JSTextField::SetShowCounter); JSClass::InheritAndBind(globalObj); } void JSTextInput::Create(const JSCallbackInfo& info) { JSTextField::CreateTextInput(info); } void JSTextInputController::JSBind(BindingTarget globalObj) { JSClass::Declare("TextInputController"); JSTextEditableController::JSBind(globalObj); } } // namespace OHOS::Ace::Framework