本文整理汇总了C++中Menu::ShowPopup方法的典型用法代码示例。如果您正苦于以下问题:C++ Menu::ShowPopup方法的具体用法?C++ Menu::ShowPopup怎么用?C++ Menu::ShowPopup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu::ShowPopup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnHover
void Menu::OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
{
Button::OnHover(position, screenPosition, buttons, qualifiers, cursor);
Menu* sibling = parent_->GetChildStaticCast<Menu>(VAR_SHOW_POPUP, true);
if (popup_ && !showPopup_)
{
// Check if popup is shown by one of the siblings
if (sibling)
{
// "Move" the popup from sibling menu to this menu
sibling->ShowPopup(false);
ShowPopup(true);
return;
}
if (autoPopup_)
{
// Show popup when parent menu has its popup shown
Menu* parentMenu = static_cast<Menu*>(parent_->GetVar(VAR_ORIGIN).GetPtr());
if (parentMenu && parentMenu->showPopup_)
ShowPopup(true);
}
}
else
{
// Hide child menu popup when its parent is no longer being hovered
if (sibling && sibling != this)
sibling->ShowPopup(false);
}
}
示例2: ShowPopup
void Menu::ShowPopup(bool enable)
{
if (!popup_)
return;
if (enable)
{
OnShowPopup();
popup_->SetVar(VAR_ORIGIN, this);
static_cast<Window*>(popup_.Get())->SetModal(true);
popup_->SetPosition(GetScreenPosition() + popupOffset_);
popup_->SetVisible(true);
// BringToFront() is unreliable in this case as it takes into account only input-enabled elements.
// Rather just force priority to max
popup_->SetPriority(M_MAX_INT);
}
else
{
OnHidePopup();
// If the popup has child menus, hide their popups as well
PODVector<UIElement*> children;
popup_->GetChildren(children, true);
for (PODVector<UIElement*>::ConstIterator i = children.Begin(); i != children.End(); ++i)
{
Menu* menu = dynamic_cast<Menu*>(*i);
if (menu)
menu->ShowPopup(false);
}
static_cast<Window*>(popup_.Get())->SetModal(false);
const_cast<VariantMap&>(popup_->GetVars()).Erase(VAR_ORIGIN);
popup_->SetVisible(false);
popup_->Remove();
}
SetVar(VAR_SHOW_POPUP, enable);
showPopup_ = enable;
selected_ = enable;
}
示例3: ShowPopup
void Menu::ShowPopup(bool enable)
{
if (!popup_)
return;
if (enable)
{
// Find the UI root element for showing the popup
UIElement* root = GetRoot();
if (!root)
return;
OnShowPopup();
if (popup_->GetParent() != root)
root->AddChild(popup_);
popup_->SetPosition(GetScreenPosition() + popupOffset_);
popup_->SetVisible(true);
popup_->SetVar(originHash, (void*)this);
popup_->BringToFront();
}
else
{
// If the popup has child menus, hide their popups as well
PODVector<UIElement*> children;
popup_->GetChildren(children, true);
for (PODVector<UIElement*>::ConstIterator i = children.Begin(); i != children.End(); ++i)
{
Menu* menu = dynamic_cast<Menu*>(*i);
if (menu)
menu->ShowPopup(false);
}
popup_->SetVar(originHash, Variant::EMPTY);
popup_->SetVisible(false);
popup_->Remove();
}
showPopup_ = enable;
selected_ = enable;
}
示例4: ShowPopup
void Menu::ShowPopup(bool enable)
{
if (!popup_)
return;
if (enable)
{
OnShowPopup();
popup_->SetVar(VAR_ORIGIN, (void*)this);
static_cast<Window*>(popup_.Get())->SetModal(true);
popup_->SetPosition(GetScreenPosition() + popupOffset_);
popup_->SetVisible(true);
popup_->BringToFront();
}
else
{
// If the popup has child menus, hide their popups as well
PODVector<UIElement*> children;
popup_->GetChildren(children, true);
for (PODVector<UIElement*>::ConstIterator i = children.Begin(); i != children.End(); ++i)
{
Menu* menu = dynamic_cast<Menu*>(*i);
if (menu)
menu->ShowPopup(false);
}
static_cast<Window*>(popup_.Get())->SetModal(false);
const_cast<VariantMap&>(popup_->GetVars()).Erase(VAR_ORIGIN);
popup_->SetVisible(false);
popup_->Remove();
}
SetVar(VAR_SHOW_POPUP, enable);
showPopup_ = enable;
selected_ = enable;
}