当前位置: 首页>>代码示例>>C++>>正文


C++ Element::AddEventListener方法代码示例

本文整理汇总了C++中rocket::core::Element::AddEventListener方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::AddEventListener方法的具体用法?C++ Element::AddEventListener怎么用?C++ Element::AddEventListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rocket::core::Element的用法示例。


在下文中一共展示了Element::AddEventListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ToggleEventListener

void UiBase::ToggleEventListener(bool toggle_on, const std::string& id, const std::string& event, RocketListener& listener)
{
  if (root)
  {
    Rocket::Core::Element* element = root->GetElementById(id.c_str());

    if (element)
    {
      Listener             registered(element, event, listener);
      auto                 it      = std::find(listeners.begin(), listeners.end(), registered);

      if (toggle_on)
      {
        if (it == listeners.end())
          listeners.push_back(registered);
        else
          element->RemoveEventListener(event.c_str(), &listener);
        element->AddEventListener(event.c_str(), &listener);
      }
      else
      {
        element->RemoveEventListener(event.c_str(), &listener);
        if (it != listeners.end())
          listeners.erase(it);
      }
    }
    else
      cout << "[WARNING] Element '" << id << "' doesn't exist." << endl;
  }
}
开发者ID:655473,项目名称:fallout-equestria,代码行数:30,代码来源:ui_base.cpp

示例2: BindEvent

void Layout::BindEvent(const string& id, UIEvent event)
{
    // Map event ID to string
    string eventID;
    switch (event)
    {
    case UI_CLICK:
        eventID = "click";
        break;

    case UI_SUBMIT:
        eventID = "submit";
        break;

    default:
        break;
    }
    
    // Look up the element
    Rocket::Core::Element* elem = mDocument->GetElementById(id.c_str());
    assert(elem);
    
    // Add the listener
    elem->AddEventListener(eventID.c_str(), mInterfaceMgr);
    mListeners.push_back(make_tuple(id, eventID, mInterfaceMgr));
}
开发者ID:davedissian,项目名称:dawnengine,代码行数:26,代码来源:Layout.cpp

示例3: initRocket

void GuiDemo::initRocket()
{
	GK_ASSERT(m_scene && !m_rkContext);

	gkWindow* window = m_scene->getDisplayWindow();
	// Rocket initialisation.
	m_rkOgreRenderer = new RenderInterfaceOgre3D(window->getWidth(), window->getHeight());
	Rocket::Core::SetRenderInterface(m_rkOgreRenderer);

	m_rkOgreSystem = new SystemInterfaceOgre3D();
	Rocket::Core::SetSystemInterface(m_rkOgreSystem);

	Rocket::Core::Initialise();
	Rocket::Controls::Initialise();


	installRocketFonts();

	m_rkContext = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(window->getWidth(), window->getHeight()));
	Rocket::Debugger::Initialise(m_rkContext);

	m_rkFileInterface = new FileInterfaceOgre3D();
	Rocket::Core::SetFileInterface(m_rkFileInterface);


	// Load the mouse cursor and release the caller's reference.
	Rocket::Core::ElementDocument* cursor = m_rkContext->LoadMouseCursor(ROCKET_CURSOR_PAGE);
	if (cursor)
		cursor->RemoveReference();

	m_document = m_rkContext->LoadDocument(ROCKET_DEMO_PAGE);
	if (m_document)
	{
		Rocket::Core::Element* button = m_document->GetElementById(DEMO_PAGE_BUTTON_ID);
		if (button)
			button->AddEventListener("click", this);
		m_document->Show();		
	}

	m_rkEventListener  = new RocketEventListener(window, m_rkContext);
	m_rkRenderListener = new RocketRenderListener(window->getRenderWindow(), m_scene->getManager(), m_rkContext);
}
开发者ID:dryadf68116,项目名称:vuforia-gamekit-integration,代码行数:42,代码来源:main.cpp

示例4: setDocument

bool MenuShit::setDocument(string _fileName)
{
	releaseDocument();

	bool success = false;

	if(context != NULL)
	{
		m_document1 = context->LoadDocument(_fileName.c_str());
		m_document2 = context->LoadDocument(_fileName.c_str());
		if(m_document1 != NULL)
		{
			m_document1->GetElementById("title")->SetInnerRML("DELUXE");
			Rocket::Core::Element *element = m_document1->GetElementById("btn");

			if(element != NULL)
			{
				m_btn1 = new ButtonEvent( m_document1, "Changed" );
				element->AddEventListener( "click", m_btn1 );
			}

			success = true;
			m_document1->Show();
			m_document1->RemoveReference();
		}
		if(m_document2 != NULL)
		{
			m_document2->GetElementById("title")->SetInnerRML("DESTINY");
			success = true;
			m_document2->Show();
			m_document2->RemoveReference();
		}
	}



	return success;
}
开发者ID:Hoodad,项目名称:LibRocket,代码行数:38,代码来源:Menu.cpp

示例5: loadGUI

void GuiDemo::loadGUI()
{
	GK_ASSERT(m_scene);

	// Install fonts
	gkGUIManager *gm = gkGUIManager::getSingletonPtr();
	gm->loadFont("Delicious-Roman");
	gm->loadFont("Delicious-Bold");
	gm->loadFont("Delicious-Italic");
	gm->loadFont("Delicious-BoldItalic");

	// Initialise the Lua interface
    Rocket::Core::Lua::Interpreter::Initialise();
    Rocket::Controls::Lua::RegisterTypes(Rocket::Core::Lua::Interpreter::GetLuaState());
	//Rocket::Core::Vector2f v; v.Normalise();


	// Create context
	gkGUI *gui = m_scene->getDisplayWindow()->getGUI();
	
	// Enable debugger (shift+~)
	gm->setDebug(gui);

	// Load the mouse cursor and release the caller's reference.
	Rocket::Core::ElementDocument* cursor = gui->getContext()->LoadMouseCursor(ROCKET_CURSOR_PAGE);
	if (cursor)
		cursor->RemoveReference();

	m_document = gui->getContext()->LoadDocument(ROCKET_DEMO_PAGE);
	if (m_document)
	{
		Rocket::Core::Element* button = m_document->GetElementById(DEMO_PAGE_BUTTON_ID);
		if (button)
			button->AddEventListener("click", this);
		m_document->Show();		
	}
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:37,代码来源:main.cpp


注:本文中的rocket::core::Element::AddEventListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。