diff --git a/frameworks/src/core/base/key_parser.cpp b/frameworks/src/core/base/key_parser.cpp index f496705..68bcd6c 100644 --- a/frameworks/src/core/base/key_parser.cpp +++ b/frameworks/src/core/base/key_parser.cpp @@ -358,7 +358,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) return K_JUSTIFY_CONTENT; } break; -#ifdef JS_TOUCH_EVENT_SUPPORT +#ifdef JS_EXTRA_EVENT_SUPPORT case 'k': if (!strcmp(s, "ey")) { return K_KEY; @@ -693,7 +693,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "ouchstart")) { return K_TOUCHSTART; } -#ifdef JS_TOUCH_EVENT_SUPPORT +#ifdef JS_EXTRA_EVENT_SUPPORT if (!strcmp(s, "ouchcancel")) { return K_TOUCHCANCEL; } diff --git a/frameworks/src/core/base/keys.h b/frameworks/src/core/base/keys.h index f82b8db..51a334a 100755 --- a/frameworks/src/core/base/keys.h +++ b/frameworks/src/core/base/keys.h @@ -147,7 +147,7 @@ enum { KEYWORD(ITEM_SELECTED, itemselected) // scroll item selected event listener KEYWORD(ITERATION, iteration) // image-animator attribute KEYWORD(JUSTIFY_CONTENT, justifyContent) // layout style -#ifdef JS_TOUCH_EVENT_SUPPORT +#ifdef JS_EXTRA_EVENT_SUPPORT KEYWORD(KEY, key) // onkey event #endif KEYWORD(LABELS, labels) // chart labels @@ -275,7 +275,7 @@ enum { KEYWORD(TOUCHSTART, touchStart) // touch event listener KEYWORD(TOUCHMOVE, touchmove) // touchmove event listener KEYWORD(TOUCHEND, touchEnd) // touchend event listener -#ifdef JS_TOUCH_EVENT_SUPPORT +#ifdef JS_EXTRA_EVENT_SUPPORT KEYWORD(TOUCHCANCEL, touchcancel) // ontouchcancel event #endif KEYWORD(TRANSLATE_X, translateX) // animation transform x diff --git a/frameworks/src/core/components/event_listener.cpp b/frameworks/src/core/components/event_listener.cpp index dfe2ec0..da604af 100755 --- a/frameworks/src/core/components/event_listener.cpp +++ b/frameworks/src/core/components/event_listener.cpp @@ -124,23 +124,18 @@ bool ViewOnTouchListener::OnDrag(UIView& view, const DragEvent& event) bool ViewOnTouchListener::OnDragEnd(UIView& view, const DragEvent &event) { - if (JSUndefined::Is(bindSwipeFunc_)) { - HILOG_ERROR(HILOG_MODULE_ACE, "OnSwipe received, but no JS function to call"); - return isStopPropagation_; + if (!JSUndefined::Is(bindSwipeFunc_)) { + JSValue argSwipe = EventUtil::CreateSwipeEvent(view, event); + EventUtil::InvokeCallback(vm_, bindSwipeFunc_, argSwipe, this); } - if (JSUndefined::Is(bindTouchEndFunc_)) { - HILOG_ERROR(HILOG_MODULE_ACE, "OnDragEnd received, but no JS function to call"); - return isStopPropagation_; + if (!JSUndefined::Is(bindTouchEndFunc_)) { + JSValue argDragEnd = EventUtil::CreateTouchEvent(view, event); + EventUtil::InvokeCallback(vm_, bindTouchEndFunc_, argDragEnd, this); } HILOG_DEBUG(HILOG_MODULE_ACE, "OnDragEnd received"); - - JSValue argSwipe = EventUtil::CreateSwipeEvent(view, event); - EventUtil::InvokeCallback(vm_, bindSwipeFunc_, argSwipe, this); - - JSValue argDragEnd = EventUtil::CreateTouchEvent(view, event); - EventUtil::InvokeCallback(vm_, bindTouchEndFunc_, argDragEnd, this); + HILOG_DEBUG(HILOG_MODULE_ACE, "Swipe received"); return isStopPropagation_; } } // namespace ACELite diff --git a/frameworks/src/core/components/event_listener.h b/frameworks/src/core/components/event_listener.h index 837a881..8ebdaef 100755 --- a/frameworks/src/core/components/event_listener.h +++ b/frameworks/src/core/components/event_listener.h @@ -175,7 +175,12 @@ class ViewOnTouchListener final : public UIView::OnDragListener { public: ACE_DISALLOW_COPY_AND_MOVE(ViewOnTouchListener); ViewOnTouchListener(jerry_value_t vm, bool isStopPropagation) - : vm_(jerry_acquire_value(vm)), isStopPropagation_(isStopPropagation) + : vm_(jerry_acquire_value(vm)), + isStopPropagation_(isStopPropagation), + bindTouchStartFunc_(UNDEFINED), + bindTouchMoveFunc_(UNDEFINED), + bindTouchEndFunc_(UNDEFINED), + bindSwipeFunc_(UNDEFINED) { }