@grimfate
hi, one more time i bother you. i got a problem with RichText,
I try to create a richtext with url. something as test project. It’ work ok.
But now, i trying to create a modal layer, then i want to show this richtext on it. But when click on url, nothing happen.
this i the code i create Modal layer:
bool ModalLayer::init()
{
if (!LayerColor::initWithColor(Color4B(0, 0, 0, 120)))
{
return false;
}
this->ignoreAnchorPointForPosition(false);
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->setSwallowTouches(true); // i need this for modal purpose. prevent user from click on other layer.
touchListener->onTouchBegan = CC_CALLBACK_2(ModalLayer::onTouchBegan, this);
touchListener->onTouchEnded = CC_CALLBACK_2(ModalLayer::onTouchEnded, this);
touchListener->onTouchMoved = CC_CALLBACK_2(ModalLayer::onTouchMoved, this);
touchListener->onTouchCancelled = CC_CALLBACK_2(ModalLayer::onTouchCancelled, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
return true;
}
bool ModalLayer::onTouchBegan(Touch* touch, Event* event)
{
auto localtouch = touch->getLocation();
if (this->boundingBox().containsPoint(localtouch))
return true;
return false;
}
void ModalLayer::onTouchEnded(Touch* touch, Event* event)
{
}
void ModalLayer::onTouchMoved(Touch* touch, Event* event)
{
}
void ModalLayer::onTouchCancelled(Touch* touch, Event* event)
{
}
then, i create a richtext on it:
auto wait = ModalLayer::create();
auto message = cocos2d::ui::RichText::createWithXML("<font face='font.ttf' size=\"20\" color=\"#000000\"> And this link will redirect you to google: <a href='http://www.google.com'>Click here </a></font>");
message->ignoreContentAdaptWithSize(false);
message->setContentSize(Size(500,400));
message->setPosition(Director::getInstance()->getVisibleSize()/2);
wait->addChild(message,10);
as i research, both modallayer with richtext use : _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); to capture event.
So when click on this, modal has swallow event. So click event on richtext do not happen.
So, how to priority event on richtext? can you help me.
thank you so much!