So I have a UIRichText added to a UIScrollView. The Scroll view scrolls fine, however the URL aspect of UIRichText don’t work. If I touch outside of the scrollview the ListenerComponent gets the touchEnd event, but it is out of the range of the URL to touch. If I touch where the UIScrollView is the ListenerCompoenent doesn’t get the touch events. Hence <a href doesn’t work.
What do I need to set/tweak to make it work?
Please check my code below
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
auto richText = RichText::createWithXML(HelperManager::GetInstance()->getStringFromEncryptedFile("config/about.til"));
richText->ignoreContentAdaptWithSize(false);
richText->setContentSize(Size(insideBg->getContentSize().width*0.94f, 0));
richText->formatText();
const float k_actualRichText02SizeHeight = richText->getContentSize().height;
richText->setContentSize(Size(insideBg->getContentSize().width*0.94f, k_actualRichText02SizeHeight));
richText->setWrapMode(RichText::WRAP_PER_WORD);
auto scrollView = cocos2d::ui::ScrollView::create();
scrollView->ignoreAnchorPointForPosition(false);
scrollView->setAnchorPoint(Vec2(0.5f, 0.5f));
scrollView->setSize(insideBg->getContentSize());
scrollView->setDirection(cocos2d::ui::ScrollView::Direction::VERTICAL);
scrollView->setPosition(insideBg->getContentSize() / 2);
scrollView->setInnerContainerSize(Size(insideBg->getContentSize().width, k_actualRichText02SizeHeight));
scrollView->setName("scrollView02");
scrollView->setScrollBarEnabled(true);
scrollView->setSwallowTouches(false);
scrollView->addChild(richText);
richText->setPosition(Vec2(scrollView->getContentSize().width / 2, k_actualRichText02SizeHeight / 2.0f));
insideBg->addChild(scrollView);
1 Like
system
closed
February 15, 2021, 3:41am
#3
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
Solved all my problems. Thank you.