Add ability to focus a button in an E_Dialog by either its number or a

pointer to it.

When we click a button we need to send a focus signal to it.


SVN revision: 16940
This commit is contained in:
codewarrior 2005-09-25 21:33:48 +00:00 committed by codewarrior
parent e9e7bfd9ec
commit d4ebde128e
3 changed files with 69 additions and 14 deletions

View File

@ -1131,7 +1131,7 @@ ACT_FN_GO(exit)
e_dialog_icon_set(dia, "enlightenment/exit", 64);
e_dialog_button_add(dia, _("Yes"), NULL, _e_actions_cb_exit_dialog_ok, NULL);
e_dialog_button_add(dia, _("No"), NULL, NULL, NULL);
e_dialog_button_focus(dia, 1);
e_dialog_button_focus_num(dia, 1);
e_win_centered_set(dia->win, 1);
e_dialog_show(dia);
}

View File

@ -19,6 +19,7 @@ struct _E_Dialog_Button
static void _e_dialog_free(E_Dialog *dia);
static void _e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _e_dialog_button_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event);
static void _e_dialog_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event);
static void _e_dialog_cb_delete(E_Win *win);
static void _e_dialog_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event);
@ -115,6 +116,7 @@ e_dialog_button_add(E_Dialog *dia, char *label, char *icon, void (*func) (void *
edje_object_part_text_set(db->obj, "button_text", db->label);
evas_object_event_callback_add(db->obj, EVAS_CALLBACK_MOUSE_IN, _e_dialog_button_cb_mouse_in, dia);
evas_object_event_callback_add(db->obj, EVAS_CALLBACK_MOUSE_DOWN, _e_dialog_button_cb_mouse_down, db);
if (icon)
{
@ -141,13 +143,17 @@ e_dialog_button_add(E_Dialog *dia, char *label, char *icon, void (*func) (void *
}
int
e_dialog_button_focus(E_Dialog *dia, int button)
e_dialog_button_focus_num(E_Dialog *dia, int button)
{
E_Dialog_Button *db = NULL;
if (button < 0)
return 0;
db = evas_list_nth(dia->buttons, button);
if (!db) return 0;
if (!db)
return 0;
if (dia->focused)
{
@ -164,6 +170,34 @@ e_dialog_button_focus(E_Dialog *dia, int button)
return 1;
}
int
e_dialog_button_focus_button(E_Dialog *dia, E_Dialog_Button *button)
{
E_Dialog_Button *db = NULL;
if (!button)
return 0;
db = evas_list_find(dia->buttons, button);
if (!db)
return 0;
if (dia->focused)
{
E_Dialog_Button *focused;
focused = dia->focused->data;
if (focused)
edje_object_signal_emit(focused->obj, "unfocus", "");
}
dia->focused = evas_list_find_list(dia->buttons, button);
edje_object_signal_emit(db->obj, "focus", "");
return 1;
}
void
e_dialog_title_set(E_Dialog *dia, char *title)
{
@ -244,8 +278,11 @@ _e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission,
E_Dialog_Button *db;
db = data;
if (db->func)
db->func(db->data, db->dialog);
if (db->func)
{
edje_object_signal_emit(db->obj, "focus", "");
db->func(db->data, db->dialog);
}
else
e_object_del(E_OBJECT(db->dialog));
}
@ -256,6 +293,18 @@ _e_dialog_button_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event)
edje_object_signal_emit(obj, "enter", "");
}
static void
_e_dialog_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event)
{
E_Dialog *dia;
E_Dialog_Button *db;
db = data;
dia = db->dialog;
e_dialog_button_focus_button(dia, db);
}
/* TODO: Implement shift-tab and left arrow */
static void
_e_dialog_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event)

View File

@ -124,8 +124,7 @@ static void _e_entry_smart_del(Evas_Object *object)
E_Entry_Smart_Data *e_entry_sd;
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
return;
return;
}
static void _e_entry_smart_raise(Evas_Object *object)
@ -133,7 +132,9 @@ static void _e_entry_smart_raise(Evas_Object *object)
E_Entry_Smart_Data *e_entry_sd;
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
return;
return;
evas_object_raise(e_entry_sd->edje_object);
}
static void _e_entry_smart_lower(Evas_Object *object)
@ -141,7 +142,9 @@ static void _e_entry_smart_lower(Evas_Object *object)
E_Entry_Smart_Data *e_entry_sd;
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
return;
return;
evas_object_lower(e_entry_sd->edje_object);
}
static void _e_entry_smart_stack_above(Evas_Object *object, Evas_Object *above)
@ -150,6 +153,8 @@ static void _e_entry_smart_stack_above(Evas_Object *object, Evas_Object *above)
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
return;
evas_object_stack_above(e_entry_sd->edje_object, above);
}
static void _e_entry_smart_stack_below(Evas_Object *object, Evas_Object *below)
@ -157,7 +162,9 @@ static void _e_entry_smart_stack_below(Evas_Object *object, Evas_Object *below)
E_Entry_Smart_Data *e_entry_sd;
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
return;
return;
evas_object_stack_below(e_entry_sd->edje_object, below);
}
static void _e_entry_smart_move(Evas_Object *object, Evas_Coord x, Evas_Coord y)
@ -196,6 +203,8 @@ static void _e_entry_smart_hide(Evas_Object *object)
if (!object || !(e_entry_sd = evas_object_smart_data_get(object)))
return;
evas_object_hide (e_entry_sd->edje_object);
}
/* Called when the user presses a key */
@ -226,9 +235,6 @@ _e_entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event)
e_editable_text_insert(obj, key_event->string);
}
Evas_Object *e_editable_text_add(Evas *evas)
{
Evas_Object *o;