- added hack for disabling actions on hidden windows. FIX ME
[enigma2.git] / lib / gui / elistbox.cpp
index 1dae137fdab5b0f99b0498fade511e0d9ad6fe32..7764e6b5d503a9a19ecc4f621fac5ccae3c34c56 100644 (file)
@@ -22,11 +22,17 @@ eListbox::~eListbox()
 void eListbox::setContent(iListboxContent *content)
 {
        m_content = content;
+       if (content)
+               m_content->setListbox(this);
        entryReset();
 }
 
 void eListbox::moveSelection(int dir)
 {
+               /* refuse to do anything without a valid list. */
+       if (!m_content)
+               return;
+               
                /* we need the old top/sel to see what we have to redraw */
        int oldtop = m_top;
        int oldsel = m_selected;
@@ -98,6 +104,8 @@ int eListbox::event(int event, void *data, void *data2)
        {
                ePtr<eWindowStyle> style;
                
+               if (!m_content)
+                       return eWidget::event(event, data, data2);
                assert(m_content);
                recalcSize(); // move to event
                
@@ -122,8 +130,12 @@ int eListbox::event(int event, void *data, void *data2)
                return 0;
        }
        case evtAction:
-               moveSelection((int)data2);
-               return 1;
+               if (isVisible())
+               {
+                       moveSelection((int)data2);
+                       return 1;
+               }
+               break;
        default:
                return eWidget::event(event, data, data2);
        }
@@ -183,9 +195,9 @@ void eListbox::entryChanged(int index)
 
 void eListbox::entryReset()
 {
-       invalidate();
        if (m_content)
                m_content->cursorHome();
        m_top = 0;
        m_selected = 0;
+       invalidate();
 }