示例#1
0
	void Console::notifyButtonPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char)
	{
		MyGUI::EditBox* edit = _sender->castType<MyGUI::EditBox>();
		size_t len = edit->getCaption().length();
		if ((_key == MyGUI::KeyCode::Backspace) && (len > 0) && (mAutocomleted))
		{
			edit->deleteTextSelection();
			len = edit->getCaption().length();
			edit->eraseText(len - 1);
		}

		MyGUI::UString command = edit->getCaption();
		if (command.length() == 0)
			return;

		for (MapDelegate::iterator iter = mDelegates.begin(); iter != mDelegates.end(); ++iter)
		{
			if (iter->first.find(command) == 0)
			{
				if (command == iter->first) break;
				edit->setCaption(iter->first);
				edit->setTextSelection(command.length(), iter->first.length());
				mAutocomleted = true;
				return;
			}
		}
		mAutocomleted = false;
	}
示例#2
0
void PlayState::notifyButtonPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char)
{
    size_t len = _sender->getCaption().length();
    MyGUI::Edit* edit = _sender->castType<MyGUI::Edit>();
    if ((_key == MyGUI::KeyCode::Backspace) && (len > 0) && (mAutocompleted)) {
        edit->deleteTextSelection();
        len = _sender->getCaption().length();
        edit->eraseText(len-1);
    }

    MyGUI::UString command = _sender->getCaption();
    if (command.length() == 0) return;

    mAutocompleted = false;
}