[mythtv] MythPopupBox losing focus
Philippe C.Cattin
cattin at vision.ee.ethz.ch
Thu Oct 9 16:40:55 EDT 2003
Isaac,
> The best thing to do would be to have MythPopupBox (or MythDialog, really)
> make its own focusNextPrevChild() method to override the default QWidget one.
> That way, it can restrict focus to the popup box's own children, and not pass
> the decision of what to move focus to up the widget tree. I'll look into
> doing this if no one else manages to get to it by the weekend.
>
> Isaac
okay, I have a solution that does the job for MythPopupBox. It
dynamically generates a QPtrList with the QButton widgets we possible
want to cycle through (thus ignoring QLabels and stuff).
However, in case of MythDialog there are more widgets that can have
user interaction. But what widgets should I check for??? Or should I
cycle through all the widgets exept QLabel,...???
Is there a better solution than the dynamic_cast hack to find out
what kind of widget I'm dealing with?
any suggestions?
regards, Philippe
### ### ###
bool MythPopupBox::focusNextPrevChild(bool next)
{
if (!widgetList)
{
selected=0;
// Recursively generate list of all children
QObjectList *l = queryList(NULL,NULL,false,true);
QObjectListIt it(*l); // iterate over all the children
// Generate list of all widgets we want to cycle through
widgetList = new QPtrList<QWidget>();
while ((objs = it.current()) != 0)
{
if (dynamic_cast<QButton*>(objs))
{
QWidget *widget = (QWidget *)objs;
if(widget->hasFocus())
selected=widgetList->count();
widgetList->append(widget);
}
++it;
}
delete l; // delete the list, not the objects
}
if(next)
{
selected++;
if(selected>=(int)widgetList->count())
selected=0;
}
else
{
selected--;
if(selected<0)
selected=widgetList->count()-1;
}
widgetList->at(selected)->setFocus();
return true;
}
More information about the mythtv-dev
mailing list