cocos2d-x如何解決 CCEditBox在 安卓平台下面不響應touch的問題

來源:互聯網
上載者:User

     使用如下的代碼來添加  CCEditBox到類中,作為輸入框 ,代碼如下:

    

    //add input  預設錨點(0.5,0.5),修改也沒用,然後這個座標不能用基於layer的    //座標,必須用 基於螢幕的座標    m_tf_input  = CCEditBox::create(CCSizeMake(280 * 0.5, 60* 0.5), CCScale9Sprite::create("ui_blank.png"));    m_tf_input->setFontColor(ccWHITE);    m_tf_input->setPlaceHolder(LanguageManager::sharedLanguageManager()->getLocalizedString("Click here and input").c_str());    m_tf_input->setText("");    m_tf_input->setMaxLength(MAX_CHAT_MSG_LENGTH);    m_tf_input->setReturnType(kKeyboardReturnTypeSend);    m_tf_input->setDelegate(this);    this->addChild(m_tf_input);        m_tf_input->setPosition(ccp(                                m_originPoint.x + this->getPosition().x +  m_size.width * 0.5  - 130 *0.5f,                                m_originPoint.y + this->getPosition().y + m_size.height* 0.5  - 184 *0.5f));    

在IOS平台輸入沒有任何問題,但是到安卓平台下面就不能接受輸入,後面發現設定touch的優先順序就ok了。

CCEditBox 是從CCControlButton  繼承,然後 

CCControlButton從  CCControl  繼承,然後 

CCControl 有個函數 

m_tf_input->setDefaultTouchPriority(-128); 就解決了。

 因為 它的預設優先順序是 1,在安卓下面優先順序不夠。




相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.