1 /* 2 * Copyright (c) 2021-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 #ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_INTERACTABLE_VIEW_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_INTERACTABLE_VIEW_H 18 19 #include "frameworks/bridge/declarative_frontend/jsview/js_pan_handler.h" 20 #include "frameworks/bridge/declarative_frontend/jsview/js_touch_handler.h" 21 #include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h" 22 #include "frameworks/core/components_ng/gestures/tap_gesture.h" 23 #include "frameworks/core/gestures/tap_gesture.h" 24 #include "frameworks/core/pipeline/base/component.h" 25 26 namespace OHOS::Ace::Framework { 27 28 using RemoteCallback = std::function<void(const BaseEventInfo* info)>; 29 30 class JSInteractableView { 31 public: 32 static void JsOnTouch(const JSCallbackInfo& args); 33 static void JsOnPan(const JSCallbackInfo& args); 34 static void JsOnClick(const JSCallbackInfo& info); 35 static void JsTouchable(const JSCallbackInfo& info); 36 static void JsOnHover(const JSCallbackInfo& info); 37 static void JsOnKey(const JSCallbackInfo& args); 38 static void JsOnKeyPreIme(const JSCallbackInfo& args); 39 static void SetFocusable(bool focusable); 40 static void SetFocusNode(bool isFocusNode); 41 static void JsMonopolizeEvents(const JSCallbackInfo& info); 42 43 static void JsOnAppear(const JSCallbackInfo& info); 44 static void JsOnDisAppear(const JSCallbackInfo& info); 45 static void JsOnAttach(const JSCallbackInfo& info); 46 static void JsOnDetach(const JSCallbackInfo& info); 47 static void JsOnDelete(const JSCallbackInfo& info); 48 static void JsOnAccessibility(const JSCallbackInfo& info); 49 static void JsCommonRemoteMessage(const JSCallbackInfo& info); 50 51 static std::function<void()> GetRemoteMessageEventCallback(const JSCallbackInfo& info); 52 #if !defined(PREVIEW) && defined(OHOS_PLATFORM) 53 static void ReportClickEvent(const WeakPtr<NG::FrameNode>& node, const std::string text = ""); 54 #endif 55 56 protected: 57 static void JsRemoteMessage(const JSCallbackInfo& info, RemoteCallback& remoteCallback); 58 59 private: 60 static void SplitString(const std::string& str, char tag, std::vector<std::string>& strList); 61 }; // class JSInteractableView 62 63 } // namespace OHOS::Ace::Framework 64 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_INTERACTABLE_VIEW_H 65