本文整理汇总了C++中rocket::core::Element::GetTagName方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::GetTagName方法的具体用法?C++ Element::GetTagName怎么用?C++ Element::GetTagName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rocket::core::Element
的用法示例。
在下文中一共展示了Element::GetTagName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessEvent
void RocketMenuPlugin::ProcessEvent(Rocket::Core::Event& event) {
Rocket::Core::Element *element = event.GetCurrentElement();
if (event.GetType() == "click") {
if (element->GetTagName() == "ftr") {
SetNextItemValue(element->GetParentNode()->GetParentNode());
event.StopPropagation();
} else if (element->GetTagName() == "hdr") {
SetPreviousItemValue(element->GetParentNode()->GetParentNode());
event.StopPropagation();
} else {
DoItemAction(ItemActionEnter, element);
}
} else if (event.GetType() == "mousemove") {
if (element->GetTagName() == "div") {
HighlightItem(element);
} else if (element->GetTagName() == "key1") {
Rocket::Core::Element *menu_item = element->GetParentNode()->GetParentNode();
SetActiveKeySlot(menu_item, 0);
} else if (element->GetTagName() == "key2") {
Rocket::Core::Element *menu_item = element->GetParentNode()->GetParentNode();
SetActiveKeySlot(menu_item, 1);
}
} else if (event.GetType() == "change") {
if (m_delegate != NULL && element->GetOwnerDocument()->IsVisible()) {
Rocket::Core::Element *menu_item = element->GetParentNode()->GetParentNode();
RangeData *data = GetRangeData(menu_item);
const Rocket::Core::Dictionary *p = event.GetParameters();
float v = p->Get("value")->Get<float>();
float new_value = data->min + v*(data->max - data->min);
if (fabs(new_value-data->value) > 0.001f) {
data->value = new_value;
m_delegate->DidChangeRangeValue(menu_item, data->value);
}
}
}
}
示例2: doCapture
bool RocketUIManager::doCapture(Rocket::Core::Context* ctx)
{
Rocket::Core::Element* e = ctx->GetHoverElement();
if(e && e != ctx->GetRootElement())
{
if(e->GetTagName() == "body")
return false;
bool isVisible = true;
while(e && (isVisible = e->IsVisible()))
{
e = e->GetParentNode();
}
return isVisible;
}
return false;
}
示例3: saveGameClicked
void SaveMenu::saveGameClicked(Rocket::Core::Event& event)
{
Rocket::Core::Element* target = event.GetTargetElement();
// Move up the DOM to the datagridrow item holding this element
while(target->GetParentNode() != nullptr && target->GetTagName() != "datagridrow")
{
target = target->GetParentNode();
}
if(target != nullptr)
{
// If we found a row element, cast it and get its index
Rocket::Controls::ElementDataGridRow* rowElement = dynamic_cast<Rocket::Controls::ElementDataGridRow*>(target);
if(rowElement != nullptr)
{
int saveGameIndex = rowElement->GetParentRelativeIndex();
showConfirmDialog(saveGameIndex);
}
}
}
示例4: on_mouseup
/// \brief Event listener callback for "mouseup" events generated by libRocket.
///
/// \param ev The object containing event info.
/// \param store The UIDataViewList widget to use.
/// \param db The cards database to use for comparison against model
/// (table) data.
/// \param model The data source model to use.
/// \param player_hand The mock player hand object to use for holding card
/// data, such as totals on number of cards of a type.
void on_mouseup( Rocket::Core::Event& ev,
UIDataViewList* store,
const std::shared_ptr<CardCollection> db,
std::shared_ptr<CardsPageDataSource> model,
std::map<int,Card>& player_hand )
{
EXPECT_TRUE( store != nullptr );
EXPECT_TRUE( db != nullptr );
EXPECT_TRUE( model != nullptr );
// ID of card selection
int selection = 0;
Rocket::Core::Element* target = ev.GetTargetElement();
if( ev == "mouseup" )
{
Rocket::Core::Input::KeyIdentifier button =
(Rocket::Core::Input::KeyIdentifier) ev.GetParameter<int>("button", 3);
EXPECT_TRUE( model->per_page() == model->GetNumRows("cards") );
EXPECT_EQ( 57, model->num_rows() );
if( target ) {
Card card = model->lookup_by_name( target->GetInnerRML().CString() );
selection = card.id();
if( target->GetTagName() == "card" && button == 0 ) // Left click
{
// Card selection logic; player hand receives a card
//
// 1. Decrease available card count by one
// 2. Sync the cards model to reflect modified card count (-1)
// 3. Update player hand w/ a copy of the reference card
if( card.num() > 0 )
{
card.set_num( card.num() - 1 );
model->insert_card(selection, card);
player_hand[card.id()] = card;
}
} // end if button == 0
else if( target->GetTagName() == "card" && button == 1 ) // Right click
{
// Compare the selected card from the current model with the game
// database; we rely on the game database to be the "safe" -- read-only.
Card ref_card = db->lookup_by_id(selection);
// Card selection logic; player hand removes a card
//
// 1. Increase available card count by one
// 2. Sync the cards model to reflect modified card count (+1)
// 3. Remove the card from the player's hand
if( card.num() < ref_card.num() )
{
card.set_num( card.num() + 1 );
model->insert_card(selection, card);
player_hand.erase( card.id() );
}
} // end if button == 1
NOM_LOG_INFO( NOM_LOG_CATEGORY_TEST, "Card ID:", selection );
NOM_LOG_INFO( NOM_LOG_CATEGORY_TEST, "Card name:", target->GetInnerRML().CString() );
} // end if target
} // end if click
} // end func on_mouseup