Exemple #1
0
bool CUIChatText::OnTextClick(CCPoint touchPos)
{
	int index = 0;
	bool isfound = false;

	std::vector<NDNode*> vChildren = this->GetChildren();
	for (std::vector<NDNode*>::iterator it = vChildren.begin(); it != vChildren.end(); it++)
	{
		NDUINode* uinode = dynamic_cast<NDUINode*> (*it);
		if (uinode && IsPointInside(touchPos, uinode->GetScreenRect()))
		{
			//NDLog(@"click on chat ui node");
			isfound=true;
			break;
		}
		index++;
	}

	if(!isfound)
	{
		return false;
	}

	ChatNode cnode = this->textNodeList[index];

	if (cnode.textType==ChatSpeaker)
	{
		//NDLog(@"click on chat speaker:%d",cnode.content_id);
		BaseScriptMgrObj.excuteLuaFunc<bool>("OnChatNodeClick", "ChatDataFunc",
			(int)cnode.textType,cnode.content_id,this->speakerName);
	}
	else if(cnode.textType==ChatItem)
	{
		//NDLog(@"click on chat item:%d",cnode.content_id);
		BaseScriptMgrObj.excuteLuaFunc<bool>("OnChatNodeClick", "ChatDataFunc",
			(int)cnode.textType,cnode.content_id,"");
	}
	else if (cnode.textType==ChatRole)
	{
		//NDLog(@"click on chat Role:%d",cnode.content_id);
		BaseScriptMgrObj.excuteLuaFunc<bool>("OnChatNodeClick", "ChatDataFunc",
			(int)cnode.textType,cnode.content_id,cnode.content_str);
	}
	else
	{
		//NDLog(@"click nothing");
	}
	return true;
}
Exemple #2
0
bool NDUITableLayer::DispatchTouchEndEvent(CGPoint beginTouch, CGPoint endTouch)
{
    if (NDUILayer::DispatchTouchEndEvent(beginTouch, endTouch))
        return true;

    if (m_curSection)
    {
        for (unsigned int i = 0; i < m_curSection->Count(); i++)
        {
            NDUINode* cell = m_curSection->Cell(i);
            CGRect rect = cell->GetScreenRect();

            if (CGRectContainsPoint(rect, m_endTouch))
            {
                if (CGRectContainsPoint(rect, beginTouch))
                {
                    if (m_curSection->GetFocusCellIndex() != i)
                    {
                        this->SetFocusOnCell(i);
                    }

                    if (!m_selectEventFocustFirst || m_curSection->GetFocusCellIndex() == i)
                    {
                        NDUITableLayerDelegate* delegate = dynamic_cast<NDUITableLayerDelegate*> (this->GetDelegate());
                        if (delegate)
                        {
                            delegate->OnTableLayerCellSelected(this, cell, i, m_curSection);
                        }
                        else
                        {
                            NDUITargetDelegate* targetDelegate = this->GetTargetDelegate();
                            if (targetDelegate)
                            {
                                targetDelegate->OnTargetTableEvent(this, cell, i, m_curSection);
                            }
                        }
                    }

                    return true;
                }
            }
        }
    }

    return false;
}
Exemple #3
0
bool NDUIXBoardHitProxy::UITouchBegin(NDTouch* pkTouch)
{
	NDUILayer* pkLayer = 0;

	if (!canProcessTouch(pkLayer))
	{
		if (pkLayer)
		{
			bool ret = pkLayer->UITouchBegin(pkTouch);

			return ret;
		}
	}

	assert(m_pkOwner && pkTouch);

	if (!IsVisible())
	{
		return false;
	}

	//判断是否点击在其他ZOrder比较高的控件上
	NDUIDialog* pkOwnerDialog = getOwnerDlg();
	if (pkOwnerDialog)
	{
		const vector<NDNode*>& kChildrenVector = pkOwnerDialog->GetChildren();
		for (int i = 0; i < kChildrenVector.size(); i++)
		{
			NDNode* pkNode = kChildrenVector[i];
			if (pkNode && pkNode->IsA(RTCLS(NDUINode)))
			{
				NDUINode* pkUINode = static_cast<NDUINode*>(pkNode);
				if (pkUINode != this && pkUINode != GetParent()
					&& pkUINode->IsA(RTCLS(NDUINode))
					&& pkUINode->GetZOrder() > GetZOrder()
					&& pkUINode->GetEnabled()
					&& pkUINode->GetScreenRect().containsPoint(
					pkTouch->GetLocation()))
				{
					return false;
				}
			}
		}
	}

	//------------------------------------------------------------
	m_kTouchDownLocalPos = pkTouch->GetLocation();
	m_pkTouchDownView = NULL;

	if (!hitTest(pkTouch->GetLocation()))
		return false;

	for (int i = 0; i < m_pkOwner->getViewCount(); i++)
	{
		NDUIXView* pkView = m_pkOwner->getViewAt(i);
		if (pkView && pkView->GetEnabled()
			&& pkView->GetScreenRect().containsPoint(
			pkTouch->GetLocation()))
		{
			m_pkTouchDownView = pkView;
			bool ret = pkView->UITouchBegin(pkTouch);
			//return ret;
		}
	}

	return true;
	//return NDUILayer::UITouchBegin(touch);
}