1 /*
2 * Copyright (c) 2022 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
17 #include "adapter/preview/entrance/editing/text_input_connection_impl.h"
18
19 #include "adapter/preview/entrance/editing/text_input_client_mgr.h"
20
21 namespace OHOS::Ace::Platform {
22
Show(bool isFocusViewChanged,int32_t instanceId)23 void TextInputConnectionImpl::Show(bool isFocusViewChanged, int32_t instanceId)
24 {}
25
SetEditingState(const TextEditingValue & value,int32_t instanceId,bool needFireChangeEvent)26 void TextInputConnectionImpl::SetEditingState(
27 const TextEditingValue& value, int32_t instanceId, bool needFireChangeEvent)
28 {
29 if (taskExecutor_ && Attached()) {
30 taskExecutor_->PostTask(
31 [value, instanceId, needFireChangeEvent] {
32 TextInputClientMgr::GetInstance().SetTextEditingValue(value);
33 },
34 TaskExecutor::TaskType::PLATFORM, "ArkUITextEditingSetValue");
35 }
36 }
37
Close(int32_t instanceId)38 void TextInputConnectionImpl::Close(int32_t instanceId)
39 {
40 // Set the current client id to invalid value.
41 TextInputClientMgr::GetInstance().ResetClientId();
42 TextInputClientMgr::GetInstance().SetCurrentConnection(nullptr);
43 if (Attached()) {
44 LOGE("Text input connection close failed.");
45 }
46 }
47
Attached()48 bool TextInputConnectionImpl::Attached()
49 {
50 return TextInputClientMgr::GetInstance().IsCurrentConnection(this);
51 }
52
53 } // namespace OHOS::Ace::Platform
54