[mythtv] MythPopupBox losing focus

Renchi Raju renchi at pooh.tam.uiuc.edu
Thu Oct 9 10:17:39 EDT 2003


just a wild guess... if you make the popupbox modal, then focus will be
restricted to the popupbox's children

renchi

On Thu, 9 Oct 2003, Philippe C.Cattin wrote:

> 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