本文整理汇总了C++中cegui::Editbox::getSelectionLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Editbox::getSelectionLength方法的具体用法?C++ Editbox::getSelectionLength怎么用?C++ Editbox::getSelectionLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cegui::Editbox
的用法示例。
在下文中一共展示了Editbox::getSelectionLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CopyToClipboard
void ControllerUI::CopyToClipboard(::CEGUI::Window* EditBox, bool Cut)
{
if (!EditBox)
return;
// get possibly typed instances we process
CEGUI::Editbox* box = dynamic_cast<CEGUI::Editbox*>(EditBox);
CEGUI::MultiLineEditbox* mlbox = dynamic_cast<CEGUI::MultiLineEditbox*>(EditBox);
// type of Editbox
if (box)
{
// get text from cegui textbox
::CEGUI::String boxStr = box->getText();
size_t start = box->getSelectionStartIndex();
size_t len = box->getSelectionLength();
// get substring which is selected
boxStr = boxStr.substr(start, len);
// copy to clipboard
if (boxStr.length() > 0)
{
::System::Windows::Forms::Clipboard::SetText(StringConvert::CEGUIToCLR(boxStr));
if (Cut)
box->eraseSelectedText();
}
}
// type of MultiLineEditbox
else if (mlbox)
{
// get text from cegui textbox
::CEGUI::String boxStr = mlbox->getText();
size_t start = mlbox->getSelectionStartIndex();
size_t len = mlbox->getSelectionLength();
// get substring which is selected
boxStr = boxStr.substr(start, len);
// copy to clipboard
if (boxStr.length() > 0)
{
::System::Windows::Forms::Clipboard::SetText(StringConvert::CEGUIToCLR(boxStr));
if (Cut)
mlbox->eraseSelectedText();
}
}
};
示例2: HandleEnterKey
//.........这里部分代码省略.........
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;
}
示例3: GUI_Paste_From_Clipboard
bool GUI_Paste_From_Clipboard( void )
{
CEGUI::Window *sheet = CEGUI::System::getSingleton().getGUISheet();
// no sheet
if( !sheet )
{
return 0;
}
CEGUI::Window *window_active = sheet->getActiveChild();
// no active window
if( !window_active )
{
return 0;
}
const CEGUI::String &type = window_active->getType();
// MultiLineEditbox
if( type.find( "/MultiLineEditbox" ) != CEGUI::String::npos )
{
CEGUI::MultiLineEditbox *editbox = static_cast<CEGUI::MultiLineEditbox*>(window_active);
if( editbox->isReadOnly() )
{
return 0;
}
CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
CEGUI::String::size_type len = editbox->getSelectionLength();
CEGUI::String new_text = editbox->getText();
// erase selected text
new_text.erase( beg, len );
// get clipboard text
CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(Get_Clipboard_Content().c_str());
// set new text
editbox->setText( new_text.insert( beg, clipboard_text ) );
// set new carat index
editbox->setCaratIndex( editbox->getCaratIndex() + clipboard_text.length() );
}
// Editbox
else if( type.find( "/Editbox" ) != CEGUI::String::npos )
{
CEGUI::Editbox *editbox = static_cast<CEGUI::Editbox*>(window_active);
if( editbox->isReadOnly() )
{
return 0;
}
CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
CEGUI::String::size_type len = editbox->getSelectionLength();
CEGUI::String new_text = editbox->getText();
// erase selected text
new_text.erase( beg, len );
// get clipboard text
CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(Get_Clipboard_Content().c_str());
// set new text
editbox->setText( new_text.insert( beg, clipboard_text ) );
// set new carat index
editbox->setCaratIndex( editbox->getCaratIndex() + clipboard_text.length() );
}
else
{
return 0;
}
return 1;
}
示例4: GUI_Copy_To_Clipboard
bool GUI_Copy_To_Clipboard( bool cut )
{
CEGUI::Window *sheet = CEGUI::System::getSingleton().getGUISheet();
// no sheet
if( !sheet )
{
return 0;
}
CEGUI::Window *window_active = sheet->getActiveChild();
// no active window
if( !window_active )
{
return 0;
}
CEGUI::String sel_text;
const CEGUI::String &type = window_active->getType();
// MultiLineEditbox
if( type.find( "/MultiLineEditbox" ) != CEGUI::String::npos )
{
CEGUI::MultiLineEditbox *editbox = static_cast<CEGUI::MultiLineEditbox*>(window_active);
CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
CEGUI::String::size_type len = editbox->getSelectionLength();
sel_text = editbox->getText().substr( beg, len ).c_str();
// if cutting
if( cut )
{
if( editbox->isReadOnly() )
{
return 0;
}
CEGUI::String new_text = editbox->getText();
editbox->setText( new_text.erase( beg, len ) );
}
}
// Editbox
else if( type.find( "/Editbox" ) != CEGUI::String::npos )
{
CEGUI::Editbox *editbox = static_cast<CEGUI::Editbox*>(window_active);
CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
CEGUI::String::size_type len = editbox->getSelectionLength();
sel_text = editbox->getText().substr( beg, len ).c_str();
// if cutting
if( cut )
{
if( editbox->isReadOnly() )
{
return 0;
}
CEGUI::String new_text = editbox->getText();
editbox->setText( new_text.erase( beg, len ) );
}
}
else
{
return 0;
}
Set_Clipboard_Content( sel_text.c_str() );
return 1;
}