Fixed InputView Next/Done button state when next after focused item is removed. 71/65571/1
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Mon, 11 Apr 2016 11:01:03 +0000 (14:01 +0300)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Mon, 11 Apr 2016 11:02:02 +0000 (14:02 +0300)
Change-Id: I91fc0c4234934f15fbbc210dca077ec47ad0d169
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-contacts/inc/Contacts/Input/ContactTextFieldControl.h
lib-contacts/src/Contacts/Input/ContactTextFieldControl.cpp

index 6567638..11e9097 100644 (file)
@@ -48,6 +48,7 @@ namespace Contacts
                         */
                        ContactTextFieldControl(Ui::GenlistItem *parent,
                                        Model::ContactTextField &field);
+                       virtual ~ContactTextFieldControl() override;
 
                        /**
                         * @brief Save the control value into the field.
@@ -83,6 +84,8 @@ namespace Contacts
 
                private:
                        virtual void onCreated() override;
+                       void setNextItem(Ui::GenlistItem *item);
+                       void unsetNextItem();
 
                        void onChanged(Evas_Object *entry, void *eventInfo);
                        void onFocused(Evas_Object *entry, void *eventInfo);
index ca1e8d2..94d75bb 100644 (file)
@@ -45,6 +45,11 @@ ContactTextFieldControl::ContactTextFieldControl(Ui::GenlistItem *parent,
 {
 }
 
+ContactTextFieldControl::~ContactTextFieldControl()
+{
+       unsetNextItem();
+}
+
 void ContactTextFieldControl::save()
 {
        if (!m_IsChanged) {
@@ -71,10 +76,10 @@ void ContactTextFieldControl::update()
 
 void ContactTextFieldControl::updateReturnKey()
 {
-       m_NextItem = nullptr;
+       unsetNextItem();
        for (auto item = m_ParentItem->getNextItem(); item; item = item->getNextItem()) {
                if (item->isFocusable()) {
-                       m_NextItem = item;
+                       setNextItem(item);
                        break;
                }
        }
@@ -123,6 +128,20 @@ void ContactTextFieldControl::onCreated()
        update();
 }
 
+void ContactTextFieldControl::setNextItem(Ui::GenlistItem *item)
+{
+       m_NextItem = item;
+       m_NextItem->setDestroyCallback(std::bind(&ContactTextFieldControl::updateReturnKey, this));
+}
+
+void ContactTextFieldControl::unsetNextItem()
+{
+       if (m_NextItem) {
+               m_NextItem->setDestroyCallback(nullptr);
+               m_NextItem = nullptr;
+       }
+}
+
 void ContactTextFieldControl::onChanged(Evas_Object *entry, void *eventInfo)
 {
        if (m_IsUpdating) {
@@ -145,6 +164,7 @@ void ContactTextFieldControl::onFocused(Evas_Object *entry, void *eventInfo)
 void ContactTextFieldControl::onUnfocused(Evas_Object *entry, void *eventInfo)
 {
        save();
+       unsetNextItem();
 }
 
 void ContactTextFieldControl::onActivated(Evas_Object *entry, void *eventInfo)