Exemplo n.º 1
0
	void ControllerUI::PasteFromClipboard(::CEGUI::Window* EditBox)
	{
		if (!EditBox || !::System::Windows::Forms::Clipboard::ContainsText())
			return;

		// get text from clipboard
		::System::String^ clipText = ::System::Windows::Forms::Clipboard::GetText(
			::System::Windows::Forms::TextDataFormat::Text);
		
		// no text
		if (!clipText || clipText->Length == 0)
			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 && !box->isReadOnly())
		{					
			// replace newline characters
			clipText = clipText->Replace(
				::System::Environment::NewLine, ::System::String::Empty);

			// get caretindex
			size_t caretindex = box->getCaretIndex();

			// insert new text
			box->insertText(StringConvert::CLRToCEGUI(clipText), caretindex);

			// set caret at the end of inserted text
			box->setCaretIndex(caretindex + clipText->Length);
		}

		// type of MultiLineEditbox
		else if (mlbox && !mlbox->isReadOnly())
		{
			// get caretindex
			size_t caretindex = mlbox->getCaretIndex();

			// insert new text
			mlbox->insertText(StringConvert::CLRToCEGUI(clipText), caretindex);

			// set caret at the end of inserted text
			mlbox->setCaretIndex(caretindex + clipText->Length);
		}
	};
Exemplo n.º 2
0
void GuiChat::writeMessage(Event* event)
{
	if (event->hasProperty("Perso") && event->hasProperty("Message"))
	{
		std::string message = event->getProperty("Perso") + " > " + event->getProperty("Message");
		// add this entry to the command history buffer
		d_history.push_back(message);
		// reset history position
		d_historyPos = d_history.size();
		// append newline to this entry
		message += '\n';
		// get history window
		CEGUI::MultiLineEditbox* history = static_cast<CEGUI::MultiLineEditbox*>(chatWindow->getChild("ListOfMessage"));
		// append new text to history output
		history->setText(history->getText() + message);
		// scroll to bottom of history output
		history->setCaretIndex(static_cast<size_t>(-1));
	}

}