elementry/ctxpopup - added event_hook, focus_hook
authorhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 28 Aug 2011 02:38:48 +0000 (02:38 +0000)
committerhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 28 Aug 2011 02:38:48 +0000 (02:38 +0000)
also enable the focus when ctxpopup shows up.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@62892 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elc_ctxpopup.c

index 8b663fd..8f62775 100644 (file)
@@ -39,6 +39,11 @@ static void _freeze_off(void *data, Evas_Object *obj, void *event_info);
 static void _hold_on(void *data, Evas_Object *obj, void *event_info);
 static void _hold_off(void *data, Evas_Object *obj, void *event_info);
 static void _scroller_size_reset(Widget_Data *wd);
+static void _on_focus_hook(void *data, Evas_Object *obj);
+static Eina_Bool _event_hook(Evas_Object *obj,
+                             Evas_Object *src,
+                             Evas_Callback_Type type,
+                             void *event_info);
 static void _hover_parent_callbacks_del(Evas_Object *obj);
 static void _hover_parent_resize(void *data, Evas *e,
                                  Evas_Object *obj,
@@ -167,6 +172,42 @@ _scroller_size_reset(Widget_Data *wd)
 }
 
 static void
+_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   if (elm_widget_focus_get(obj))
+     {
+        //FIXME: 
+     }
+   else
+     {
+        //FIXME:
+     }
+}
+
+static Eina_Bool
+_event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
+{
+   Evas_Event_Key_Down *ev;
+   Widget_Data *wd;
+
+   if (type != EVAS_CALLBACK_KEY_DOWN)
+     return EINA_FALSE;
+   wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+
+   ev = event_info;
+   if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
+   if (strcmp(ev->keyname, "Escape")) return EINA_FALSE;
+
+   evas_object_hide(obj);
+   ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+   return EINA_TRUE;
+}
+
+static void
 _hover_parent_callbacks_del(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
@@ -845,6 +886,8 @@ _ctxpopup_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
    edje_object_signal_emit(wd->base, "elm,state,show", "elm");
 
    _sizing_eval(obj);
+
+   elm_object_focus_set(obj, EINA_TRUE);
 }
 
 static void
@@ -1059,6 +1102,9 @@ elm_ctxpopup_add(Evas_Object *parent)
    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
    elm_widget_del_hook_set(obj, _del_hook);
    elm_widget_theme_hook_set(obj, _theme_hook);
+   elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
+   elm_widget_can_focus_set(obj, EINA_TRUE);
+   elm_widget_event_hook_set(obj, _event_hook);
    elm_widget_content_set_hook_set(obj, _content_set_hook);
    elm_widget_content_unset_hook_set(obj, _content_unset_hook);
    elm_widget_content_get_hook_set(obj, _content_get_hook);