• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_FIELD_TEXT_FIELD_CONTROLLER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_FIELD_TEXT_FIELD_CONTROLLER_H
18 
19 #include "base/memory/ace_type.h"
20 
21 namespace OHOS::Ace {
22 
23 class Element;
24 
25 class ACE_EXPORT TextFieldController : public AceType {
26     DECLARE_ACE_TYPE(TextFieldController, AceType);
27 public:
SetHandler(WeakPtr<Element> element)28     void SetHandler(WeakPtr<Element> element)
29     {
30         element_ = element;
31     }
32 
33     void Focus(bool focus);
34 
35     void ShowError(const std::string& errorText);
36     void Delete();
37     void Insert(const std::string& args);
38 
39     void CaretPosition(int32_t caretPosition);
40 
SetCaretPosition(std::function<void (const int32_t)> setCaretPosition)41     void SetCaretPosition(std::function<void(const int32_t)> setCaretPosition)
42     {
43         setCaretPosition_ = setCaretPosition;
44     }
45 
46 private:
47     WeakPtr<Element> element_;
48     std::function<void(const int32_t)> setCaretPosition_;
49 };
50 
51 } // namespace OHOS::Ace
52 
53 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_FIELD_TEXT_FIELD_CONTROLLER_H
54