예제 #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 EnvironmentDialog::notifyEditTextChange(MyGUI::EditBox* _sender)
  {
    if (_sender == mStartFog)
    {
      mStart = MyGUI::utility::parseFloat(mStartFog->getCaption());
      SetFog();
    }
    else
    if (_sender == mEndFog)
    {
      mEnd = MyGUI::utility::parseFloat(mEndFog->getCaption());
      SetFog();
    }
    else
    {
      MyGUI::EditBox* edit = static_cast<MyGUI::EditBox*>(_sender);
      size_t cursor = edit->getTextCursor();
      size_t num = MyGUI::utility::parseSizeT(edit->getCaption());
      if (num > 255) num = 255;
      edit->setCaption(MyGUI::utility::toString(num));
      if (cursor < edit->getTextLength()) edit->setTextCursor(cursor);

      mFogColour = ColourValue(
        MyGUI::utility::parseFloat(mEditRed->getCaption()) / 255.0f,
        MyGUI::utility::parseFloat(mEditGreen->getCaption()) / 255.0f,
        MyGUI::utility::parseFloat(mEditBlue->getCaption()) / 255.0f);

      SetFog();
    } 
  }
예제 #3
0
SimpleData SimpleDataUI::get( string name ){
	assert( mParent );
	SimpleData sd;

	for( size_t i = 0;i<mParent->getChildCount();++i ){
		MyGUI::Widget* pw = mParent->getChildAt(i); 
		SimpleData* psd = pw->getUserData<SimpleData>(false);
		if( psd && psd->name==name ){
			MyGUI::UString us;
			MyGUI::EditBox* pe = pw->castType<MyGUI::EditBox>(false);
			if( pe ){
				us = pe->getCaption();
				if( psd->type==SimpleData::STRING )
					psd->str = us;
				else if( psd->type==SimpleData::REAL ){
					try{
						psd->real = boost::lexical_cast<Ogre::Real>( us );
					}catch( boost::bad_lexical_cast& e ){
						MYGUI_LOG(Warning,e.what());
					}
				}
			}
			return *psd;
		}
	}
	return sd;
}