//------------------------------------------------------------------------------ GUITeamSelect::GUITeamSelect(PuppetMasterClient * puppet_master) : puppet_master_(puppet_master) { enableFloatingPointExceptions(false); CEGUI::WindowManager& wm = CEGUI::WindowManager::getSingleton(); /// XXX hack because root window is stored inside metatask, no easy way to retrieve it CEGUI::Window * parent = wm.getWindow("TankApp_root/"); // Use parent window name as prefix to avoid name clashes root_ = wm.loadWindowLayout("teamselectmenu.layout", parent->getName()); menu_window_ = (CEGUI::Window*) wm.getWindow(parent->getName() + "teamselectmenu/menu"); menu_btn_[0] = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn1"); menu_btn_[1] = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn2"); menu_btn_spec_ = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn3"); menu_btn_text_[0] = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn1/text"); menu_btn_text_[1] = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn2/text"); // add score to widget tree parent->addChildWindow(menu_window_); menu_window_->setVisible(false); registerCallbacks(); enableFloatingPointExceptions(); s_input_handler.registerInputCallback("Change Team", input_handler::SingleInputHandler(this, &GUITeamSelect::toggleShow), &fp_group_); }
bool CEGUIInputHandler::mousePressed( const ApplicationMouseCode::MouseButton button) { //BOOST_LOG_SEV(mBoostLogger, boost::log::trivial::debug)<< "MOUSE BUTTON PRESSED" << button; CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext(); // Saving a mathgl graph to a file on right click CEGUI::Window* window = context.getWindowContainingMouse(); if (window != NULL && (window->getName() == "MathGLWindow" || window->getName() == "MathGLRTTWindow") && button == ApplicationMouseCode::RightButton) { std::vector<MathGLPanel*>::iterator it = SimulationManager::getSingleton()->getViewController().getGraphWindows().begin(); for (; it != SimulationManager::getSingleton()->getViewController().getGraphWindows().end(); it++) { if ((*it)->getMathGlWindow() == window || (*it)->getMathGlWindow()->getChild("MathGLRTTWindow") == window) { (*it)->makePrint(); } } } context.injectMouseButtonDown(InputUtils::convertToCEGUI(button)); return OgreInputHandler::mousePressed(button); }
void GUISystem::FolderSelector::Show(const CEGUI::String& windowTitle, bool showEditbox, const CEGUI::String& editboxLabel) { bool success = false; OC_CEGUI_TRY; { CEGUI::Window* root = gGUIMgr.GetGUISheet(); mWindow = gGUIMgr.LoadSystemLayout("FolderSelector.layout", root->getName() + "/"); mWindow->setAlwaysOnTop(true); mWindow->setModalState(true); root->addChildWindow(mWindow); CEGUI::Window* frame = mWindow->getChild(root->getName() + "/FolderSelector/Frame"); frame->setText(windowTitle); mButtonOK = frame->getChild(root->getName() + "/FolderSelector/ButtonOK"); mButtonCancel = frame->getChild(root->getName() + "/FolderSelector/ButtonCancel"); mPathBox = frame->getChild(root->getName() + "/FolderSelector/PathBox"); mFolderList = static_cast<CEGUI::Listbox*>(frame->getChild(root->getName() + "/FolderSelector/FolderList")); mFolderList->setWantsMultiClickEvents(true); mEditbox = frame->getChild(root->getName() + "/FolderSelector/Editbox"); mEditbox->subscribeEvent(CEGUI::Editbox::EventKeyDown, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnEditboxKeyDown, this)); mButtonOK->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnButtonClicked, this)); mButtonCancel->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnButtonClicked, this)); mFolderList->subscribeEvent(CEGUI::Listbox::EventMouseDoubleClick, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnFolderListDoubleClicked, this)); CEGUI::Window* buttonCreateDirectory = frame->getChild(root->getName() + "/FolderSelector/ButtonCreateDirectory"); buttonCreateDirectory->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnCreateDirectoryClicked, this)); if (!showEditbox) { mEditbox->hide(); frame->getChild(root->getName() + "/FolderSelector/EditboxLabel")->hide(); } else { frame->getChild(root->getName() + "/FolderSelector/EditboxLabel")->setText(editboxLabel); mEditbox->activate(); } UpdateFolderList(); success = true; } OC_CEGUI_CATCH; if (!success) { ocError << "Cannot show FolderSelector."; delete this; } }
//通知创建一个新窗口 BOOL CDataPool::OnCreateNewWindow(CEGUI::Window* pWinParent) { CEGUI::Window* pWindow = NULL; if (m_szCreateWindowType.IsEmpty()) { g_pEditorView->setCreateWindowFlag(false); g_pEditorView->setCreateWindow(NULL); return FALSE; } ////显示名字对话框 //CCreateWindowDlg dlg(pWinParent == NULL); //if (dlg.DoModal() == IDCANCEL) //{ // return FALSE; //} //CString name ; //name = dlg.m_szDefaultName; //if (name.IsEmpty()) //{ // g_pEditorView->setCreateWindowFlag(false); // g_pEditorView->setCreateWindow(NULL); // return FALSE; //} //创建窗口 try { pWindow = WindowManager::getSingleton().createWindow(m_szCreateWindowType.GetString()/*, name.GetString()*/); pWindow->setClippedByParent(true); //pWindow->setPosition(CEGUI::Absolute, Point(0,0)); pWindow->setSize(CEGUI::Absolute, Size(100,100)); if (pWinParent == NULL) { System::getSingleton().getGUISheet()->addChildWindow(pWindow); g_leftTreeWindow->InsertItemToTree(pWindow->getName().c_str(), NULL); } else { pWinParent->addChildWindow(pWindow); CString szParentPath = GetParentTreePath(pWindow); g_leftTreeWindow->InsertItemToTree(pWindow->getName().c_str(), szParentPath); } g_pEditorView->setCreateWindow(pWindow); return TRUE; } catch (...) { MessageBox(AfxGetMainWnd()->GetSafeHwnd(), "创建窗口出现未知错误", "提示", MB_OK); } return FALSE; }
//------------------------------------------------------------------------ void Selection::SelectChildren(const CEGUI::Window* aWindow) { for (size_t i=0; i<aWindow->getChildCount(); i++) { CEGUI::Window* child = aWindow->getChildAtIdx(i); // Skip __auto windows if (child->getName().find("__auto_") == String::npos && child->getName().find("__TabPane__")) { // Add as an non-resizable box m_allBoxes.push_back (WindowBox(child, false)); // Recurse! SelectChildren(child); } } }
void CUIEditorView::OnRButtonDown(UINT nFlags, CPoint point) { g_CoreSystem.getCEGUISystem()->injectMousePosition(point.x, point.y); g_CoreSystem.getCEGUISystem()->injectMouseButtonDown(CEGUI::RightButton); if( getShowMode() == false ) return; CMenu menu; menu.CreatePopupMenu(); CEGUI::Window* mouseWindow = g_CoreSystem.getCEGUISystem()->getWindowContainingMouse(); bool showMenu = false; INT menuId = ID_RIGHT_WINDOW_SELECT; for ( ; mouseWindow ; mouseWindow = mouseWindow->getParent(),++menuId ) { if (mouseWindow != CEGUI::System::getSingleton().getGUISheet() && !mouseWindow->isAutoWindow()) { menu.AppendMenu(MF_STRING, menuId,mouseWindow->getName().c_str()); showMenu = true; } } if (showMenu) { POINT pos; GetCursorPos(&pos); menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,pos.x, pos.y, this); g_DataPool.OnSelectWindowChanged(NULL, m_pSelectedWindow); } CView::OnRButtonDown(nFlags, point); }
void CUIEditorView::OnLButtonDblClk(UINT nFlags, CPoint point) { g_CoreSystem.getCEGUISystem()->injectMouseButtonDown(CEGUI::LeftButton); //找到鼠标点击的窗口 CEGUI::Window* pWin = CEGUI::System::getSingleton().getWindowContainingMouse(); if(pWin) { //检测窗口是否可以显示函数对话框 BOOL bShow = g_DataPool.m_scriptModule.DoFunction("canShowFunctionDlg",pWin->getWidgetType().c_str(),NULL); //显示对话框 if(bShow) { CFunctionDlg dlg; CString szString,szName; szName = pWin->getName().c_str(); szString = szName; szString += "_OnClicked"; dlg.SetLeftFunction(szString); szString = szName; szString += "_OnRClicked"; dlg.SetRightFunction(szString); dlg.SetWindowName(szName); dlg.DoModal(); } } CView::OnLButtonDblClk(nFlags, point); }
void CUIEditorView::setWindowSelected(const CEGUI::String& name,bool addEvent /*= true*/) { try { if( name.length()> 0 && name != m_nSelectWindowName) { if(name == "___Shower_Window____") return; CEGUI::Window* pWindow = CEGUI::WindowManager::getSingleton().getWindow(name); CEGUI::Window* pOldSel = NULL; if (pWindow && !pWindow->isAutoWindow()) { if(m_nSelectWindowName.length() > 0) { pOldSel = CEGUI::WindowManager::getSingleton().getWindow(m_nSelectWindowName); if (pOldSel) { for(;pOldSel && pOldSel != CEGUI::System::getSingleton().getGUISheet(); pOldSel = pOldSel->getParent()) { pOldSel->unsubscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this)); } } } //pWindow->moveToFront(); m_nSelectWindowName = pWindow->getName(); CEGUI::Window* pSet = pWindow; for (; pSet&& pSet !=CEGUI::System::getSingleton().getGUISheet(); pSet = pSet->getParent() ) { pSet->subscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this)); } CEGUI::Rect rect = pWindow->getPixelRect(); setSelectWindowPos(CRect(rect.d_left, rect.d_top, rect.getWidth(), rect.getHeight())); m_ptMouseMovePos = CPoint(0,0); } m_pSelectedWindow = pWindow; updateCurrentWindowStatusText(); if (addEvent) { g_DataPool.OnSelectWindowChanged(pOldSel,pWindow); } } else if (name.length() == 0) { if (addEvent) { g_DataPool.OnSelectWindowChanged(m_pSelectedWindow,NULL); } m_nSelectWindowName = ""; setSelectWindowPos(CRect(), true); m_pSelectedWindow = NULL; } } catch(CEGUI::UnknownObjectException& e) { } }
void CDataPool::OnPropertyChange(const CString &szName, const CString& szValue, CEGUI::Window* pSpecialWindow/* = NULL*/) { try { CEGUI::Window* pWin = pSpecialWindow ? pSpecialWindow : m_pCurrentSelectWindow; if (pWin) { //需要转化成utf8 if(szName == "Text" || szName == "Tooltip" || szName == "Name") { if (szName == "Name") { CString szPath = GetParentTreePath(pWin); if (szPath.IsEmpty()) { szPath = pWin->getName().c_str(); } g_leftTreeWindow->onRenameSelectWindow(szValue,pWin->getName().c_str(), szPath); pWin->setName((CEGUI::utf8*)mbcs_to_utf8(szValue.GetString())); g_pEditorView->onRenameSelectedWindow(szValue,pWin); } else { pWin->setProperty(szName.GetString(), (CEGUI::utf8*)mbcs_to_utf8(szValue.GetString())); } } else { pWin->setProperty(szName.GetString(), szValue.GetString()); } } } catch (CEGUI::Exception& e) { MessageBox(AfxGetMainWnd()->GetSafeHwnd(), e.what(), "改变属性出错信息", MB_OK); } }
// event checkBoxCheckedChanged(checkBoxName) bool OnCheckboxCheckStateChanged(const CEGUI::EventArgs &eventArgs) { CEvents * pEvents = g_pClient->GetEvents(); String eventName("checkBoxCheckedChanged"); if(!pEvents->IsEventRegistered(eventName)) return false; CEGUI::Window * pWindow = static_cast<const CEGUI::WindowEventArgs&>(eventArgs).window; CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow); CSquirrelArguments pArguments; pArguments.push(pWindow->getName().c_str()); pEvents->Call(eventName, &pArguments, pScript); return true; }
// event guiMouseLeave(guiName) bool OnMouseLeaves(const CEGUI::EventArgs &eventArgs) { CEvents * pEvents = g_pClient->GetEvents(); String eventName("guiMouseLeave"); if(!pEvents->IsEventRegistered(eventName)) return false; const CEGUI::MouseEventArgs eArgs = static_cast<const CEGUI::MouseEventArgs&>(eventArgs); CEGUI::Window * pWindow = eArgs.window; CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow); CSquirrelArguments pArguments; pArguments.push(pWindow->getName().c_str()); pEvents->Call(eventName, &pArguments, pScript); return true; }
// event buttonClick(buttonName, bState) // TODO: remove it. We have better alternative guiClick (OnClick) for any gui element bool OnButtonClick(const CEGUI::EventArgs &eventArgs) { CEvents * pEvents = g_pClient->GetEvents(); String eventName("buttonClick"); if(!pEvents->IsEventRegistered(eventName)) return false; CEGUI::Window * pWindow = static_cast<const CEGUI::WindowEventArgs&>(eventArgs).window; CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow); CSquirrelArguments pArguments; pArguments.push(pWindow->getName().c_str()); pArguments.push(0); // FIXME or what? pEvents->Call(eventName, &pArguments, pScript); return true; }
bool OnUpdateLatestBuy(const CEGUI::EventArgs& e) { CEGUI::Window* wnd = WEArgs(e).window; //先把图片清掉 ,默认为十个条目 char name[256] = ""; for(uint i = 0 ; i < 10 ; ++i) { sprintf(name,SHOPCITY_LATESTBUY_ITME_NAME_D,i); CEGUI::Window* temp = wnd->getChild(name); if(temp) { temp->setProperty("Image",""); OutputDebugStr(temp->getName().c_str()); OutputDebugStr("\n"); } } //由索引关联商城类型 SCGData::eSCType eCityType = GetShopCityTypeByTabContentSelIndex(); SCGData* dt = GetInst(ShopCityMsgMgr).GetShopCityGoodsData(); SCGData::MapSBT10& personal = dt->GetSelfBuyTop10(); SCGData::VecGDPTA perDTA = personal[eCityType]; size_t count = perDTA.size(); for(size_t i = 0 ; i < count ; ++i) { char name[256] = ""; sprintf(name,SHOPCITY_LATESTBUY_ITME_NAME_D,i); CEGUI::Window* temp = wnd->getChild(name); if(temp) { CGoodsList::tagGoods2* tg2 = CGoodsList::GetProperty(perDTA[i].index); if(tg2) { char imagesetname[256]; sprintf(imagesetname,GOODS_PREFIXID,tg2->BaseProperty.dwIconId); CEGUI::String imagename = CEGUI::PropertyHelper::intToString(tg2->BaseProperty.dwIconId)+".jpg"; SetBackGroundImage(WGUISheet(temp),imagesetname,GOODS_ICON_PATH,imagename.c_str()); } } } return true; }
// event windowClose(windowName) bool OnWindowClose(const CEGUI::EventArgs &eventArgs) { CEvents * pEvents = g_pClient->GetEvents(); String eventName("windowClose"); if(!pEvents->IsEventRegistered(eventName)) return false; CEGUI::Window * pWindow = static_cast<const CEGUI::WindowEventArgs&>(eventArgs).window; CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow); CSquirrelArguments pArguments; pArguments.push(pWindow->getName().c_str()); // Event handler must return 1 to close window, otherwise, 0. CSquirrelArgument pReturn = pEvents->Call(eventName, &pArguments, pScript); if(pReturn.GetInteger()) pWindow->hide(); return true; }
bool OnPlayerShopSubBuyNum(const CEGUI::EventArgs& e) { CEGUI::Window* wnd = WEArgs(e).window; if(!wnd) return false; CEGUI::Window* goodsWnd = wnd->getParent(); if (goodsWnd) { CGoods* goods = static_cast<CGoods*>(goodsWnd->getUserData()); if (!goods) return false; PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods); if (pGoodsItem!=NULL) { char str[32]; // 取得输入框控件名 CEGUI::String name = wnd->getName(); name.assign(name, 0, name.find_last_of("/")); name += "/BuyNum"; CEGUI::Window* buyNumWnd = GetWndMgr().getWindow(name); int num = atoi(buyNumWnd->getText().c_str()); if (num<=0) { sprintf(str,"%d",0); wnd->disable(); } else sprintf(str,"%d",num--); buyNumWnd->setText(ToCEGUIString(str)); pGoodsItem->readyTradeNum = num; } } return true; }
/*********************************************************** handle send button event ***********************************************************/ bool ChatBox::HandleEnterKey (const CEGUI::EventArgs& e) { const CEGUI::KeyEventArgs& we = static_cast<const CEGUI::KeyEventArgs&>(e); const CEGUI::WindowEventArgs& wine = static_cast<const CEGUI::WindowEventArgs&>(e); if(we.scancode == CEGUI::Key::LeftControl || we.scancode == CEGUI::Key::RightControl) { _control_key_on = true; return true; } if(we.scancode == CEGUI::Key::LeftShift || we.scancode == CEGUI::Key::RightShift) { _shift_key_on = true; return true; } if(wine.window->getName() == "Chat/edit") { if(we.scancode == CEGUI::Key::Return) { HandleSend (e); CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")); bed->deactivate(); return true; } if(we.scancode == CEGUI::Key::ArrowUp) { if(_itltext == _lasttexts.end()) _itltext = _lasttexts.begin(); else { std::list<std::string>::iterator ittmp = _itltext; ++ittmp; if(ittmp != _lasttexts.end()) ++_itltext; } try { if(_itltext != _lasttexts.end()) { CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText( (const unsigned char *)_itltext->c_str()); } else { CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText(""); } } catch(...){} return true; } if(we.scancode == CEGUI::Key::ArrowDown) { if(_itltext != _lasttexts.end()) { if(_itltext != _lasttexts.begin()) --_itltext; else _itltext = _lasttexts.end(); } if(_itltext != _lasttexts.end()) { CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText( (const unsigned char *)_itltext->c_str()); } else { CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText(""); } return true; } if(we.scancode == CEGUI::Key::ArrowUp || we.scancode == CEGUI::Key::ArrowDown) return true; // paste text if(we.scancode == CEGUI::Key::V && _control_key_on) { CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")); if(bed->isActive()) { if(_text_copyed != "") { size_t selB = bed->getSelectionStartIndex(); size_t selE = bed->getSelectionLength(); CEGUI::String str = bed->getText(); if(selE > 0) { str = str.erase(selB, selE); } if(str.size() + _text_copyed.size() < bed->getMaxTextLength()) { size_t idx = bed->getCaratIndex(); str = str.insert(idx, (unsigned char *)_text_copyed.c_str()); bed->setText(str); bed->setCaratIndex(idx + _text_copyed.size()); } } return true; } } } // copy text if(we.scancode == CEGUI::Key::C && _control_key_on) { CEGUI::Window * actw = _myChat->getActiveChild(); if(actw != NULL) { if(actw->getName() == "Chat/edit") { CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (actw); size_t selB = bed->getSelectionStartIndex(); size_t selE = bed->getSelectionLength(); if(selE > 0) { CEGUI::String str = bed->getText().substr(selB, selE); _text_copyed = str.c_str(); } return true; } else { CEGUI::MultiLineEditbox* txt = static_cast<CEGUI::MultiLineEditbox *>(actw); size_t selB = txt->getSelectionStartIndex(); size_t selE = txt->getSelectionLength(); if(selE > 0) { CEGUI::String str = txt->getText().substr(selB, selE); _text_copyed = str.c_str(); } return true; } } } return false; }
void CUIEditorView::OnMouseMove(UINT nFlags, CPoint point) { g_CoreSystem.getCEGUISystem()->injectMousePosition(point.x, point.y); if( !getShowMode() ) return; //如果是创建窗口的过程 if (getCreateWindowFlag()) { //创建了窗口,那么改变他的大小 if (m_pCreatedWindow) { //setWindowSelected(m_pCreatedWindow->getName().c_str()); m_nResponseType = BRP_CREATE_NEW_WINDOW_QUAD; } SetCursor(m_BorderResponse[BRP_CREATE_NEW_WINDOW_QUAD].cursor); } else { //如果按住了CTRL那么鼠标移动的时候选择窗口 if ( isControlDown() && getShowMode() ) { CEGUI::Window* mouseWindow = g_CoreSystem.getCEGUISystem()->getWindowContainingMouse(); if (mouseWindow) { setWindowSelected(mouseWindow->getName(),false); } } //检测鼠标感应 if ( !m_bProcessing ) { m_nResponseType = BRP_INVALID; for (INT i=0; i<BRP_NUM; i++) { if( m_BorderResponse[i].hoverRect.PtInRect(point) ) { SetCursor(m_BorderResponse[i].cursor); m_nResponseType = (BorderResponsePos)i; break; } } } } //处理拖动和改变查看大小的操作 if (m_lButtonDown) { if(m_nResponseType == BRP_SELECT_WINDOW_MIDDLE_MIDDLE_QUAD) { while( ShowCursor(FALSE) > 0 ); } SetCursor(m_BorderResponse[m_nResponseType].cursor); setProcessing(true); processMoveAndSizing(point); } //显示鼠标位置 CHAR szMouseText[MAX_PATH] = {0}; sprintf(szMouseText, "鼠标(%d,%d)",point.x, point.y); ((CMainFrame*)AfxGetMainWnd())->SetStatusText(1,szMouseText); updateCurrentOperationStatusText(); SetFocus(); CView::OnMouseMove(nFlags, point); }
/*********************************************************** handle send button event ***********************************************************/ bool ChatBox::HandleEnterKey (const CEGUI::EventArgs& e) { const CEGUI::KeyEventArgs& we = static_cast<const CEGUI::KeyEventArgs&>(e); const CEGUI::WindowEventArgs& wine = static_cast<const CEGUI::WindowEventArgs&>(e); if(we.scancode == CEGUI::Key::LeftControl || we.scancode == CEGUI::Key::RightControl) { _control_key_on = true; return true; } if(we.scancode == CEGUI::Key::LeftShift || we.scancode == CEGUI::Key::RightShift) { _shift_key_on = true; return true; } if(we.scancode == CEGUI::Key::LeftAlt || we.scancode == CEGUI::Key::RightAlt) { return true; } if(wine.window->getName() == "Chat/edit") { if(we.scancode == CEGUI::Key::Return) { HandleSend (e); CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")); bed->deactivate(); return true; } if(we.scancode == CEGUI::Key::ArrowUp) { if(_itltext == _lasttexts.end()) _itltext = _lasttexts.begin(); else { std::list<std::string>::iterator ittmp = _itltext; ++ittmp; if(ittmp != _lasttexts.end()) ++_itltext; } try { CEGUI::Window *windowchat = CEGUI::WindowManager::getSingleton().getWindow("Chat/edit"); std::string text = ""; if(_itltext != _lasttexts.end()) text = *_itltext; if(windowchat) windowchat->setText((const unsigned char *)text.c_str()); } catch(...){} //++_currSelectedch; //if(_currSelectedch >= (int)_channels.size()) // --_currSelectedch; //else //{ // std::list<std::string>::const_iterator it = _channels.begin(); // std::list<std::string>::const_iterator end = _channels.end(); // for(int cc=0; cc<_currSelectedch && it != end; ++it, ++cc); // CEGUI::PushButton * bch = static_cast<CEGUI::PushButton *> // (CEGUI::WindowManager::getSingleton().getWindow("Chat/bChannel")); // bch->setProperty("Text", *it); //} return true; } if(we.scancode == CEGUI::Key::ArrowDown) { if(_itltext != _lasttexts.end()) { if(_itltext != _lasttexts.begin()) --_itltext; else _itltext = _lasttexts.end(); } CEGUI::Window *windowchat = CEGUI::WindowManager::getSingleton().getWindow("Chat/edit"); std::string text = ""; if(_itltext != _lasttexts.end()) text = *_itltext; if(windowchat) windowchat->setText((const unsigned char *)text.c_str()); //--_currSelectedch; //if(_currSelectedch < 0) // ++_currSelectedch; //else //{ // std::list<std::string>::const_iterator it = _channels.begin(); // std::list<std::string>::const_iterator end = _channels.end(); // for(int cc=0; cc<_currSelectedch && it != end; ++it, ++cc); // CEGUI::PushButton * bch = static_cast<CEGUI::PushButton *> // (CEGUI::WindowManager::getSingleton().getWindow("Chat/bChannel")); // bch->setProperty("Text", *it); //} return true; } if(we.scancode == CEGUI::Key::ArrowUp || we.scancode == CEGUI::Key::ArrowDown) return true; // paste text if(we.scancode == CEGUI::Key::V && _control_key_on) { CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")); if(bed && bed->isActive()) { if(_text_copyed != "") { size_t selB = bed->getSelectionStartIndex(); size_t selE = bed->getSelectionLength(); CEGUI::String str = bed->getText(); if(selE > 0) { str = str.erase(selB, selE); } if(str.size() + _text_copyed.size() < bed->getMaxTextLength()) { size_t idx = bed->getCaratIndex(); str = str.insert(idx, (unsigned char *)_text_copyed.c_str()); bed->setText(str); bed->setCaratIndex(idx + _text_copyed.size()); } } return true; } } } // copy text if(we.scancode == CEGUI::Key::C && _control_key_on) { CEGUI::Window * actw = _myChat->getActiveChild(); if(actw != NULL) { if(actw->getName() == "Chat/edit") { CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (actw); size_t selB = bed->getSelectionStartIndex(); size_t selE = bed->getSelectionLength(); if(selE > 0) { CEGUI::String str = bed->getText().substr(selB, selE); _text_copyed = str.c_str(); } return true; } else { CEGUI::MultiLineEditbox* txt = static_cast<CEGUI::MultiLineEditbox *>(actw); size_t selB = txt->getSelectionStartIndex(); size_t selE = txt->getSelectionLength(); if(selE > 0) { CEGUI::String str = txt->getText().substr(selB, selE); _text_copyed = str.c_str(); } return true; } } } return false; }