Ejemplo n.º 1
0
	void Console::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) && (mAutocomleted))
		{
			edit->deleteTextSelection();
			len = _sender->getCaption().length();
			edit->eraseText(len-1);
		}

		MyGUI::UString command = _sender->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;
	}
Ejemplo n.º 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;
}