diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index e7840fe83..cc89b409b 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -241,6 +241,8 @@ class CComponentsItem : public CComponents ///property: page number, this defines current item page location, means: this item is embedded in a parent container on page number n, see also setPageNumber() ///default value is 0 for page one, any value > 0 causes handling for mutilple pages at parent container uint8_t cc_page_number; + ///specifies that some certain operations especially eg. exec events for that item are possible, see also setFocus(), hasFocus() + bool cc_has_focus; ///Pointer to the form object in which this item is embedded. ///Is typically the type CComponentsForm or derived classes, default intialized with NULL @@ -269,6 +271,10 @@ class CComponentsItem : public CComponents virtual CComponentsForm* getParent(){return cc_parent;}; ///property: returns true if item is added to a form virtual bool isAdded(); + ///indicates wether item has focus + virtual bool hasFocus(){return cc_has_focus;} + ///set or unset focus of item, stand alone items without parent have always set focus to true, inside of a parent form object, always the last added item has focus + virtual void setFocus(bool focus); ///abstract: paint item, arg: do_save_bg see paintInit() above virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0; diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 5e6bfc1f7..c29ffc950 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -111,6 +111,7 @@ void CComponentsForm::addCCItem(CComponentsItem* cc_Item) //assign item index int new_index = genIndex(); cc_Item->setIndex(new_index); + cc_Item->setFocus(true); dprintf(DEBUG_DEBUG, "\t%s-%d parent index = %d, assigned index ======> %d\n", __func__, __LINE__, cc_item_index, new_index); diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index 0aeb374ce..4f0874897 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -50,6 +50,7 @@ CComponentsItem::CComponentsItem(CComponentsForm* parent) cc_item_enabled = true; cc_item_selected = false; cc_page_number = 0; + cc_has_focus = true; initParent(parent); } @@ -214,3 +215,14 @@ void CComponentsItem::setWidthP(const uint8_t& w_percent) { width = cc_parent ? w_percent*cc_parent->getWidth()/100 : w_percent*frameBuffer->getScreenWidth(true)/100; } + +void CComponentsItem::setFocus(bool focus) +{ + if(cc_parent){ + for(size_t i=0; isize(); i++){ + if (focus) + cc_parent->getCCItem(i)->setFocus(false); + } + } + cc_has_focus = focus; +}