Merge pull request #7194 from andyque/fixTouchEvent

fix touch related issue
This commit is contained in:
minggo 2014-06-25 14:05:16 +08:00
commit 728fab706e
7 changed files with 14 additions and 7 deletions

View File

@ -74,7 +74,7 @@ _fontName("Thonburi"),
_fontSize(10), _fontSize(10),
_type(FontType::SYSTEM) _type(FontType::SYSTEM)
{ {
setTouchEnabled(true);
} }
Button::~Button() Button::~Button()
@ -128,7 +128,6 @@ bool Button::init()
{ {
if (Widget::init()) if (Widget::init())
{ {
setTouchEnabled(true);
return true; return true;
} }
return false; return false;

View File

@ -62,6 +62,7 @@ _frontCrossRendererAdaptDirty(true),
_backGroundBoxDisabledRendererAdaptDirty(true), _backGroundBoxDisabledRendererAdaptDirty(true),
_frontCrossDisabledRendererAdaptDirty(true) _frontCrossDisabledRendererAdaptDirty(true)
{ {
setTouchEnabled(true);
} }
CheckBox::~CheckBox() CheckBox::~CheckBox()
@ -128,7 +129,6 @@ bool CheckBox::init()
if (Widget::init()) if (Widget::init())
{ {
setSelectedState(false); setSelectedState(false);
setTouchEnabled(true);
return true; return true;
} }
return false; return false;

View File

@ -42,7 +42,7 @@ _curSelectedIndex(0),
_refreshViewDirty(true), _refreshViewDirty(true),
_eventCallback(nullptr) _eventCallback(nullptr)
{ {
this->setTouchEnabled(true);
} }
ListView::~ListView() ListView::~ListView()
@ -505,8 +505,10 @@ void ListView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch*
} }
parent = dynamic_cast<Widget*>(parent->getParent()); parent = dynamic_cast<Widget*>(parent->getParent());
} }
if (sender->isHighlighted()) {
selectedItemEvent(event); selectedItemEvent(event);
} }
}
} }
ssize_t ListView::getCurSelectedIndex() const ssize_t ListView::getCurSelectedIndex() const

View File

@ -46,6 +46,7 @@ _pageViewEventListener(nullptr),
_pageViewEventSelector(nullptr), _pageViewEventSelector(nullptr),
_eventCallback(nullptr) _eventCallback(nullptr)
{ {
this->setTouchEnabled(true);
} }
PageView::~PageView() PageView::~PageView()

View File

@ -73,6 +73,7 @@ _scrollViewEventListener(nullptr),
_scrollViewEventSelector(nullptr), _scrollViewEventSelector(nullptr),
_eventCallback(nullptr) _eventCallback(nullptr)
{ {
setTouchEnabled(true);
} }
ScrollView::~ScrollView() ScrollView::~ScrollView()
@ -1544,6 +1545,7 @@ void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sende
switch (event) switch (event)
{ {
case TouchEventType::BEGAN: case TouchEventType::BEGAN:
_touchBeganPosition = touch->getLocation();
handlePressLogic(touch); handlePressLogic(touch);
break; break;
@ -1553,6 +1555,7 @@ void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sende
if (offset > _childFocusCancelOffset) if (offset > _childFocusCancelOffset)
{ {
sender->setHighlighted(false); sender->setHighlighted(false);
_touchMovePosition = touch->getLocation();
handleMoveLogic(touch); handleMoveLogic(touch);
} }
} }
@ -1560,6 +1563,7 @@ void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sende
case TouchEventType::CANCELED: case TouchEventType::CANCELED:
case TouchEventType::ENDED: case TouchEventType::ENDED:
_touchEndPosition = touch->getLocation();
handleReleaseLogic(touch); handleReleaseLogic(touch);
break; break;
} }

View File

@ -66,6 +66,7 @@ _barRendererAdaptDirty(true),
_progressBarRendererDirty(true), _progressBarRendererDirty(true),
_eventCallback(nullptr) _eventCallback(nullptr)
{ {
setTouchEnabled(true);
} }
Slider::~Slider() Slider::~Slider()

View File

@ -206,8 +206,9 @@ bool Widget::init()
onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this); onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this);
onNextFocusedWidget = nullptr; onNextFocusedWidget = nullptr;
this->setAnchorPoint(Vec2(0.5f, 0.5f)); this->setAnchorPoint(Vec2(0.5f, 0.5f));
ignoreContentAdaptWithSize(true); ignoreContentAdaptWithSize(true);
this->setTouchEnabled(true);
this->setCascadeColorEnabled(true); this->setCascadeColorEnabled(true);
this->setCascadeOpacityEnabled(true); this->setCascadeOpacityEnabled(true);
@ -1033,7 +1034,6 @@ void Widget::copyProperties(Widget *widget)
copySpecialProperties(widget); copySpecialProperties(widget);
//FIXME:copy focus properties, also make sure all the subclass the copy behavior is correct
Map<int, LayoutParameter*>& layoutParameterDic = widget->_layoutParameterDictionary; Map<int, LayoutParameter*>& layoutParameterDic = widget->_layoutParameterDictionary;
for (auto iter = layoutParameterDic.begin(); iter != layoutParameterDic.end(); ++iter) for (auto iter = layoutParameterDic.begin(); iter != layoutParameterDic.end(); ++iter)
{ {