本文整理汇总了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;
}
}
示例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));
}
示例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);
}
示例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;
}
示例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();
}
}