Adding focus cycle hook to Inwin and Frame.

SVN revision: 52960
This commit is contained in:
Tiago Rezende Campos Falcao 2010-10-01 19:02:58 +00:00
parent 6fd3d0b565
commit e29b0b64b4
3 changed files with 78 additions and 17 deletions

View File

@ -260,22 +260,37 @@ test_focus(void *data, Evas_Object *obj, void *event_info)
} }
{//Third Col {//Third Col
Evas_Object *tb = elm_table_add(win); Evas_Object *bx = elm_box_add(win);
evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
elm_box_pack_end(mainbx, tb); EVAS_HINT_EXPAND);
my_show(tb); elm_box_pack_end(mainbx, bx);
for (j = 0; j < 3; j++) my_show(bx);
for (i = 0; i < 3; i++)
{ {
Evas_Object *bt; Evas_Object *fr = elm_frame_add(win);
bt = elm_button_add(win); elm_frame_label_set(fr, "Frame");
elm_button_label_set(bt, "Button"); elm_box_pack_end(bx, fr);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, evas_object_show(fr);
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); {
elm_table_pack(tb, bt, i, j, 1, 1); Evas_Object *tb = elm_table_add(win);
my_show(bt); evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
} elm_frame_content_set(fr, tb);
my_show(tb);
for (j = 0; j < 3; j++)
for (i = 0; i < 3; i++)
{
Evas_Object *bt;
bt = elm_button_add(win);
elm_button_label_set(bt, "Table");
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_table_pack(tb, bt, i, j, 1, 1);
my_show(bt);
}
}
}
} }
{ //Panel { //Panel

View File

@ -46,6 +46,33 @@ _theme_hook(Evas_Object *obj)
_sizing_eval(obj); _sizing_eval(obj);
} }
static Eina_Bool
_elm_frame_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *cur;
if ((!wd) || (!wd->content))
return EINA_FALSE;
cur = wd->content;
/* Try Focus cycle in subitem */
if (elm_widget_focus_cycle(cur, dir, circular))
return EINA_TRUE;
/* Ignore focused subitem */
if (elm_widget_focus_get(cur) && (!circular))
return EINA_FALSE;
/* Try give the focus to sub item*/
if (elm_widget_can_focus_get(cur))
{
elm_widget_focus_steal(cur);
return EINA_TRUE;
}
return EINA_FALSE;
}
static void static void
_sizing_eval(Evas_Object *obj) _sizing_eval(Evas_Object *obj)
{ {
@ -107,6 +134,7 @@ elm_frame_add(Evas_Object *parent)
elm_widget_data_set(obj, wd); elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook); elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_focus_cycle_hook_set(obj, _elm_frame_focus_cycle_hook);
elm_widget_can_focus_set(obj, EINA_FALSE); elm_widget_can_focus_set(obj, EINA_FALSE);
wd->frm = edje_object_add(e); wd->frm = edje_object_add(e);

View File

@ -133,7 +133,7 @@ _elm_win_focus_out(Ecore_Evas *ee)
} }
static Eina_Bool static Eina_Bool
_elm_win_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular) _elm_win_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular __UNUSED__)
{ {
Elm_Win *wd = elm_widget_data_get(obj); Elm_Win *wd = elm_widget_data_get(obj);
Eina_List *items; Eina_List *items;
@ -143,6 +143,8 @@ _elm_win_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool c
if ((!wd) || (!wd->subobjs)) if ((!wd) || (!wd->subobjs))
return EINA_FALSE; return EINA_FALSE;
circular = EINA_TRUE;
/* Focus chain */ /* Focus chain */
/* TODO: Change this to use other chain */ /* TODO: Change this to use other chain */
items = wd->subobjs; items = wd->subobjs;
@ -2055,6 +2057,21 @@ _theme_hook(Evas_Object *obj)
_sizing_eval(obj); _sizing_eval(obj);
} }
static Eina_Bool
_elm_inwin_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular __UNUSED__)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *cur;
if ((!wd) || (!wd->content))
return EINA_FALSE;
cur = wd->content;
/* Try Focus cycle in subitem */
return elm_widget_focus_cycle(cur, dir, EINA_TRUE);
}
static void static void
_sizing_eval(Evas_Object *obj) _sizing_eval(Evas_Object *obj)
{ {
@ -2114,6 +2131,7 @@ elm_win_inwin_add(Evas_Object *obj)
elm_widget_data_set(obj2, wd); elm_widget_data_set(obj2, wd);
elm_widget_del_hook_set(obj2, _del_hook); elm_widget_del_hook_set(obj2, _del_hook);
elm_widget_theme_hook_set(obj2, _theme_hook); elm_widget_theme_hook_set(obj2, _theme_hook);
elm_widget_focus_cycle_hook_set(obj2, _elm_inwin_focus_cycle_hook);
elm_widget_can_focus_set(obj2, EINA_FALSE); elm_widget_can_focus_set(obj2, EINA_FALSE);
wd->frm = edje_object_add(win->evas); wd->frm = edje_object_add(win->evas);