本文整理汇总了C++中AutoTArray::IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoTArray::IndexOf方法的具体用法?C++ AutoTArray::IndexOf怎么用?C++ AutoTArray::IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoTArray
的用法示例。
在下文中一共展示了AutoTArray::IndexOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_QueryFrame
nsMenuFrame*
nsMenuBarFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent)
{
uint32_t charCode;
aKeyEvent->GetCharCode(&charCode);
AutoTArray<uint32_t, 10> accessKeys;
WidgetKeyboardEvent* nativeKeyEvent =
aKeyEvent->AsEvent()->WidgetEventPtr()->AsKeyboardEvent();
if (nativeKeyEvent) {
nativeKeyEvent->GetAccessKeyCandidates(accessKeys);
}
if (accessKeys.IsEmpty() && charCode)
accessKeys.AppendElement(charCode);
if (accessKeys.IsEmpty())
return nullptr; // no character was pressed so just return
// Enumerate over our list of frames.
auto insertion = PresContext()->PresShell()->FrameConstructor()->
GetInsertionPoint(GetContent(), nullptr);
nsContainerFrame* immediateParent = insertion.mParentFrame;
if (!immediateParent)
immediateParent = this;
// Find a most preferred accesskey which should be returned.
nsIFrame* foundMenu = nullptr;
size_t foundIndex = accessKeys.NoIndex;
nsIFrame* currFrame = immediateParent->PrincipalChildList().FirstChild();
while (currFrame) {
nsIContent* current = currFrame->GetContent();
// See if it's a menu item.
if (nsXULPopupManager::IsValidMenuItem(current, false)) {
// Get the shortcut attribute.
nsAutoString shortcutKey;
current->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, shortcutKey);
if (!shortcutKey.IsEmpty()) {
ToLowerCase(shortcutKey);
const char16_t* start = shortcutKey.BeginReading();
const char16_t* end = shortcutKey.EndReading();
uint32_t ch = UTF16CharEnumerator::NextChar(&start, end);
size_t index = accessKeys.IndexOf(ch);
if (index != accessKeys.NoIndex &&
(foundIndex == accessKeys.NoIndex || index < foundIndex)) {
foundMenu = currFrame;
foundIndex = index;
}
}
}
currFrame = currFrame->GetNextSibling();
}
if (foundMenu) {
return do_QueryFrame(foundMenu);
}
// didn't find a matching menu item
#ifdef XP_WIN
// behavior on Windows - this item is on the menu bar, beep and deactivate the menu bar
if (mIsActive) {
nsCOMPtr<nsISound> soundInterface = do_CreateInstance("@mozilla.org/sound;1");
if (soundInterface)
soundInterface->Beep();
}
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {
nsIFrame* popup = pm->GetTopPopup(ePopupTypeAny);
if (popup)
pm->HidePopup(popup->GetContent(), true, true, true, false);
}
SetCurrentMenuItem(nullptr);
SetActive(false);
#endif // #ifdef XP_WIN
return nullptr;
}