/** \brief Return the first MythUIType which accepts focus found at the given * coordinates * * \param p QPoint coordinates * \param recursive Whether to perform a recursive search * * \return The widget at these coordinates */ MythUIType *MythUIType::GetChildAt(const QPoint &p, bool recursive, bool focusable) const { if (GetArea().contains(p)) { if (!IsVisible() || !IsEnabled()) return NULL; if (m_ChildrenList.isEmpty()) return NULL; /* check all children */ QList<MythUIType *>::const_iterator it; for (it = m_ChildrenList.end() - 1; it != m_ChildrenList.begin() - 1; --it) { if (!(*it)) continue; // If this point doesn't fall within the child's area then move on // This requires that the area is actually accurate and in some // cases this still isn't true if (!(*it)->GetArea().contains(p - GetArea().topLeft())) continue; MythUIType *child = *it; if (recursive && (focusable && !child->CanTakeFocus())) child = child->GetChildAt(p - GetArea().topLeft(), recursive, focusable); if (child) { // NOTE: Assumes no selectible ui type will contain another // selectible ui type. if (focusable && !child->CanTakeFocus()) continue; return child; } } } return NULL; }
/** \brief Return the first MythUIType which accepts focus found at the given * coordinates * * \param p QPoint coordinates * \param recursive Whether to perform a recursive search * * \return The widget at these coordinates */ MythUIType *MythUIType::GetChildAt(const QPoint &p, bool recursive, bool focusable) const { if (GetArea().contains(p)) { if (!IsVisible() || !IsEnabled()) return NULL; if (m_ChildrenList.isEmpty()) return NULL; /* check all children */ QList<MythUIType *>::const_iterator it; for (it = m_ChildrenList.end() - 1; it != m_ChildrenList.begin() - 1; --it) { if (!(*it)) continue; MythUIType *child = NULL; if ((*it)->GetArea().contains(p - GetArea().topLeft())) child = *it; if (!child && recursive) child = (*it)->GetChildAt(p - GetArea().topLeft(), recursive, focusable); if (child) { // NOTE: Assumes no selectible ui type will contain another // selectible ui type. if (focusable && !child->CanTakeFocus()) continue; return child; } } } return NULL; }
bool MythScreenType::SetFocusWidget(MythUIType *widget) { if (!widget || !widget->IsVisible()) { QMap<int, MythUIType *>::iterator it = m_FocusWidgetList.begin(); MythUIType *current; while (it != m_FocusWidgetList.end()) { current = *it; if (current->CanTakeFocus() && current->IsVisible()) { widget = current; break; } ++it; } } if (!widget) return false; if (m_CurrentFocusWidget == widget) return true; MythUIText *helpText = dynamic_cast<MythUIText *>(GetChild("helptext")); if (helpText) helpText->Reset(); if (m_CurrentFocusWidget) m_CurrentFocusWidget->LoseFocus(); m_CurrentFocusWidget = widget; m_CurrentFocusWidget->TakeFocus(); if (helpText && !widget->GetHelpText().isEmpty()) helpText->SetText(widget->GetHelpText()); return true; }