timer: create entry focus chain 01/90601/6
authorKamil Lipiszko <k.lipiszko@samsung.com>
Sat, 1 Oct 2016 07:50:32 +0000 (09:50 +0200)
committerKamil Lipiszko <k.lipiszko@samsung.com>
Thu, 6 Oct 2016 13:10:51 +0000 (15:10 +0200)
Creates entry focus chain to provide focus changing when
current entry has already two valid digits set.

Change-Id: I973891abc7a5070906ee9e308a92c92f13567955

clock/inc/View/TimerView.h
clock/src/View/TimerView.cpp

index aadf4fa..b087874 100644 (file)
@@ -74,7 +74,6 @@ namespace view {
        private:
                Evas_Object *layout_ = NULL;
                Evas_Object *selector_ = NULL;
-               Evas_Object *alarmWin = NULL; //after RingProvider or any other implementation it needs to be removed
                view::CounterView *counter_ = NULL;
 
                utils::Time set_time_;
index 08d7dbd..83f2374 100644 (file)
@@ -73,9 +73,6 @@ void TimerView::AlarmDismiss(void *data, Evas_Object *obj, const char *emission,
 {
        TimerView *object = static_cast<TimerView *>(data);
 
-       evas_object_del(object->alarmWin);
-       object->alarmWin = NULL;
-
        object->EmitSignal(TimerSignal::BUTTON_CANCEL_CLICKED);
 
        elm_object_signal_emit(object->layout_, "menu.startup.show", "timer");
@@ -226,6 +223,8 @@ void TimerView::CreateEntry(Evas_Object *parent, const char *part)
 
        evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN, EntryEditDoneCb, this);
 
+       elm_object_focus_custom_chain_append(parent, entry, NULL);
+
        evas_object_show(entry);
 }
 
@@ -269,6 +268,17 @@ void TimerView::EntryChangedCb(void *data, Evas_Object *obj, void *event_info)
                        object->set_time_.Min,
                        object->set_time_.Sec
                        );
+
+       Evas_Object *entry = static_cast<Evas_Object *>(obj);
+
+       const Eina_List *focus_chain = elm_object_focus_custom_chain_get(object->selector_);
+       if (entry == eina_list_last_data_get(focus_chain))
+               return;
+
+       const char *text = elm_object_text_get(entry);
+       bool isFocused = elm_object_focus_get(entry);
+       if (isFocused && strlen(text) > 1)
+               elm_object_focus_next(object->selector_, ELM_FOCUS_NEXT);
 }
 
 void TimerView::EntryEditDoneCb(void *data, Evas *e, Evas_Object *obj, void *event_info)