(CEGUI)如何创建控件 ------Checkbox

//创建控件

Checkbox* cb = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox","Checkb"));
cb->setText("Are you crazy?");
cb->setArea(URect(cegui_reldim(0.1f),cegui_reldim(0.6f),cegui_reldim(0.5f),cegui_reldim(0.7f)));
MyWindow->addChildWindow(cb);

//设置回调函数

WindowManager::getSingleton().getWindow("Checkb")->subscribeEvent(Checkbox::EventCheckStateChanged,Event::Subscriber(&Demo7Sample::handleOption1,this));

 

//回调函数

bool Demo7Sample::handleOption1(const CEGUI::EventArgs& e)
{
 using namespace CEGUI;
 bool isCheck = static_cast<Checkbox*>(static_cast<const WindowEventArgs&>(e).window)->isSelected();
 if (isCheck)
 {
  MessageBox(NULL,"选中","",MB_OK);
 }else
 {
  MessageBox(NULL,"未选中","",MB_OK);
 }
 
 return true;
}

你可能感兴趣的:((CEGUI)如何创建控件 ------Checkbox)