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 JsOnHoverMove(const JSCallbackInfo& info); 38 static void JsOnKey(const JSCallbackInfo& args); 39 static void JsOnKeyPreIme(const JSCallbackInfo& args); 40 static void JsOnKeyEventDispatch(const JSCallbackInfo& args); 41 static void SetFocusable(bool focusable); 42 static void SetFocusNode(bool isFocusNode); 43 static void JsMonopolizeEvents(const JSCallbackInfo& info); 44 45 static void JsOnAppear(const JSCallbackInfo& info); 46 static void JsOnDisAppear(const JSCallbackInfo& info); 47 static void JsOnAttach(const JSCallbackInfo& info); 48 static void JsOnDetach(const JSCallbackInfo& info); 49 static void JsOnDelete(const JSCallbackInfo& info); 50 static void JsOnAccessibility(const JSCallbackInfo& info); 51 static void JsCommonRemoteMessage(const JSCallbackInfo& info); 52 53 static std::function<void()> GetRemoteMessageEventCallback(const JSCallbackInfo& info); 54 #if !defined(PREVIEW) && defined(OHOS_PLATFORM) 55 static void ReportClickEvent(const WeakPtr<NG::FrameNode>& weakNode, const std::string text = ""); 56 #endif 57 58 protected: 59 static void JsRemoteMessage(const JSCallbackInfo& info, RemoteCallback& remoteCallback); 60 61 private: 62 static void SplitString(const std::string& str, char tag, std::vector<std::string>& strList); 63 }; // class JSInteractableView 64 65 } // namespace OHOS::Ace::Framework 66 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_INTERACTABLE_VIEW_H 67