bool CContextMenuManager::OnClick(unsigned int id, const CFileItemPtr& item) { if (!item) return false; auto it = std::find_if(m_items.begin(), m_items.end(), [id](const Item& kv){ return kv.first == id; }); if (it == m_items.end()) { CLog::Log(LOGERROR, "CContextMenuManager: unknown button id '%u'", id); return false; } CContextMenuItem menuItem = it->second; if (menuItem.IsGroup()) { CLog::Log(LOGDEBUG, "CContextMenuManager: showing group '%s'", menuItem.ToString().c_str()); CContextButtons choices; AddVisibleItems(item, choices, menuItem); if (choices.empty()) { CLog::Log(LOGERROR, "CContextMenuManager: no items in group '%s'", menuItem.ToString().c_str()); return false; } int choice = CGUIDialogContextMenu::ShowAndGetChoice(choices); if (choice == -1) return false; return OnClick(choice, item); } return menuItem.Execute(item); }