X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/54bd4123728628a6f77bad2584b70d1353a91666..3af66122574386a2856e83ba9c5d73d27a6f3710:/lib/gui/elistbox.cpp diff --git a/lib/gui/elistbox.cpp b/lib/gui/elistbox.cpp index 361d7b99..a6fe45f1 100644 --- a/lib/gui/elistbox.cpp +++ b/lib/gui/elistbox.cpp @@ -1,19 +1,38 @@ #include #include +#include eListbox::eListbox(eWidget *parent): eWidget(parent) { setContent(new eListboxStringContent()); + + ePtr ptr; + eActionMap::getInstance(ptr); + + ptr->bindAction("ListboxActions", 0, 0, this); +} + +eListbox::~eListbox() +{ + ePtr ptr; + eActionMap::getInstance(ptr); + ptr->unbindAction(this, 0); } 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; @@ -85,6 +104,8 @@ int eListbox::event(int event, void *data, void *data2) { ePtr style; + if (!m_content) + return eWidget::event(event, data, data2); assert(m_content); recalcSize(); // move to event @@ -108,6 +129,9 @@ int eListbox::event(int event, void *data, void *data2) return 0; } + case evtAction: + moveSelection((int)data2); + return 1; default: return eWidget::event(event, data, data2); } @@ -167,9 +191,9 @@ void eListbox::entryChanged(int index) void eListbox::entryReset() { - invalidate(); if (m_content) m_content->cursorHome(); m_top = 0; m_selected = 0; + invalidate(); }