Today, a female colleague asked me a question, two Cocostudio UI is addchild to a layer at the same time, the UI settings in the upper level are visible to false, the visible setting of the low-level UI settings is set to True, Then the click events on the low-level UI are not clickable,
I remember that the touch event in the UIButton class is called the Ontouchbegan method in Uiwidget, and here is the process of clicking the event:
BOOL Widget::ontouchbegan (Touch *touch, Event *unusedevent)
{
_hitted = false;
if (isVisible () && isenabled () && isancestorsenabled () && isancestorsvisible (This))
{
_touchbeganposition = Touch->getlocation ();
if (HitTest (_touchbeganposition) && isclippingparentcontainspoint (_touchbeganposition))
{
_hitted = true;
}
}
if (!_hitted)
{
return false;
}
Sethighlighted (TRUE);
/*
* Propagate Touch events to its parents
*/
if (_propagatetouchevents)
{
This->propagatetouchevent (Toucheventtype::began, this, touch);
}
Pushdownevent ();
return true;
}
If the visible is false, the touch event cannot be triggered, but the visible variable of the child node is not false, so the touch events of the child nodes can also be triggered, thus masking the touch events of the low-level UI. This is the Cocostudio source developers do not think too thoughtful problem.
Reprint please indicate the source, from the blog Park Hemjohn
Cocostudio Bug (1)