diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index e402db3359..39718575f3 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -74,7 +74,7 @@ _fontName("Thonburi"), _fontSize(10), _type(FontType::SYSTEM) { - + setTouchEnabled(true); } Button::~Button() @@ -128,7 +128,6 @@ bool Button::init() { if (Widget::init()) { - setTouchEnabled(true); return true; } return false; diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index d5a3b762d0..47b4e040bb 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -62,6 +62,7 @@ _frontCrossRendererAdaptDirty(true), _backGroundBoxDisabledRendererAdaptDirty(true), _frontCrossDisabledRendererAdaptDirty(true) { + setTouchEnabled(true); } CheckBox::~CheckBox() @@ -128,7 +129,6 @@ bool CheckBox::init() if (Widget::init()) { setSelectedState(false); - setTouchEnabled(true); return true; } return false; diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index a7afc68ec4..547d492adc 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -42,7 +42,7 @@ _curSelectedIndex(0), _refreshViewDirty(true), _eventCallback(nullptr) { - + this->setTouchEnabled(true); } ListView::~ListView() @@ -505,7 +505,9 @@ void ListView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch* } parent = dynamic_cast(parent->getParent()); } - selectedItemEvent(event); + if (sender->isHighlighted()) { + selectedItemEvent(event); + } } } diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 59059870a9..1e04e9168f 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -46,6 +46,7 @@ _pageViewEventListener(nullptr), _pageViewEventSelector(nullptr), _eventCallback(nullptr) { + this->setTouchEnabled(true); } PageView::~PageView() diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index d1d6664a1c..fe350efe78 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -73,6 +73,7 @@ _scrollViewEventListener(nullptr), _scrollViewEventSelector(nullptr), _eventCallback(nullptr) { + setTouchEnabled(true); } ScrollView::~ScrollView() @@ -1544,6 +1545,7 @@ void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sende switch (event) { case TouchEventType::BEGAN: + _touchBeganPosition = touch->getLocation(); handlePressLogic(touch); break; @@ -1553,6 +1555,7 @@ void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sende if (offset > _childFocusCancelOffset) { sender->setHighlighted(false); + _touchMovePosition = touch->getLocation(); handleMoveLogic(touch); } } @@ -1560,6 +1563,7 @@ void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sende case TouchEventType::CANCELED: case TouchEventType::ENDED: + _touchEndPosition = touch->getLocation(); handleReleaseLogic(touch); break; } diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index 65886298a7..38b5bf678c 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -66,6 +66,7 @@ _barRendererAdaptDirty(true), _progressBarRendererDirty(true), _eventCallback(nullptr) { + setTouchEnabled(true); } Slider::~Slider() diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 1041ff9fc7..be7cd54206 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -206,8 +206,9 @@ bool Widget::init() onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this); onNextFocusedWidget = nullptr; this->setAnchorPoint(Vec2(0.5f, 0.5f)); + ignoreContentAdaptWithSize(true); - this->setTouchEnabled(true); + this->setCascadeColorEnabled(true); this->setCascadeOpacityEnabled(true); @@ -1033,7 +1034,6 @@ void Widget::copyProperties(Widget *widget) copySpecialProperties(widget); - //FIXME:copy focus properties, also make sure all the subclass the copy behavior is correct Map& layoutParameterDic = widget->_layoutParameterDictionary; for (auto iter = layoutParameterDic.begin(); iter != layoutParameterDic.end(); ++iter) {