Exemple #1
0
void HotkeyManager::setWidgetHotkey( const string name,const string key )
{
	MyGUI::Gui& gui = MyGUI::Gui::getInstance();
	MyGUI::Widget* p = gui.findWidget<MyGUI::Widget>( name,false );
	if( p && (p->isType<MyGUI::Button>() || p->isType<MyGUI::MenuItem>() ) )
	{
		MyGUI::MenuItem* menuitem = p->castType<MyGUI::MenuItem>(false);
		if( menuitem )
			menuitem->setUserString( "hotkey",key );
		else
			p->setUserString( "hotkey",key );
	}
}
Exemple #2
0
void HotkeyManager::_linkWidget(MyGUI::Widget* _widget)
{
	if( _widget && 
		(_widget->isType<MyGUI::MenuItem>() || 
		_widget->isType<MyGUI::Button>() ) )
	{
		string name = _widget->getName();
		if( !name.empty() )
		{
			for( HotkeyTable::iterator it = mHotkeys.begin();it!=mHotkeys.end();++it )
			{
				if( it->mName == name )
				{
					MyGUI::MenuItem* menuitem = _widget->castType<MyGUI::MenuItem>(false);
					if( menuitem )
						menuitem->setUserString("hotkey",it->mHotkey );
					else
						_widget->setUserString( "hotkey",it->mHotkey );
					return;
				}
			}
		}
	}
}