From 2cb74bebe91248789ff353a5169f0ae5c9bb1d5e Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Tue, 25 Dec 2007 18:15:26 +0000 Subject: [PATCH] Entry dialog now supports "Return" key which will call the "Ok" function. SVN revision: 33243 --- src/bin/e_entry_dialog.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/bin/e_entry_dialog.c b/src/bin/e_entry_dialog.c index 558c38c7d..999c1a843 100644 --- a/src/bin/e_entry_dialog.c +++ b/src/bin/e_entry_dialog.c @@ -5,6 +5,7 @@ static void _e_entry_dialog_free(E_Entry_Dialog *dia); static void _e_entry_dialog_ok(void *data, E_Dialog *dia); static void _e_entry_dialog_cancel(void *data, E_Dialog *dia); static void _e_entry_dialog_delete(E_Win *win); +static void _e_entry_cb_key_down(void *data, Evas_Object *obj, void *event_info); /* Externally accesible functions */ EAPI E_Entry_Dialog * @@ -49,6 +50,7 @@ e_entry_dialog_show(const char *title, const char *icon, const char *text, } ed->entry = e_widget_entry_add(dia->win->evas, &(ed->text), NULL, NULL, NULL); + evas_object_smart_callback_add(ed->entry, "key_down", _e_entry_cb_key_down, ed); e_widget_list_object_append(o, ed->entry, 1, 1, 0.5); e_widget_min_size_get(o, &w, &h); e_dialog_content_set(dia, o, w, h); @@ -66,6 +68,7 @@ static void _e_entry_dialog_free(E_Entry_Dialog *ed) { e_object_del(E_OBJECT(ed->dia)); + evas_object_smart_callback_del(ed->entry, "key_down", _e_entry_cb_key_down); E_FREE(ed->text); free(ed); } @@ -104,3 +107,18 @@ _e_entry_dialog_delete(E_Win *win) ed = dia->data; e_object_del(E_OBJECT(ed)); } + +static void +_e_entry_cb_key_down(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Event_Key_Down *ev; + E_Entry_Dialog *ed; + + ev = event_info; + if (strcmp(ev->keyname, "Return")) return; + if (!(ed = data)) return; + e_object_ref(E_OBJECT(ed)); + if (ed->ok.func) ed->ok.func(ed->text, ed->ok.data); + e_object_del(E_OBJECT(ed)); + e_object_unref(E_OBJECT(ed)); +}