1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
8 _focus_in(void *data __UNUSED__, Evas *e __UNUSED__, void *event_info)
10 const char *type = evas_object_type_get(event_info);
11 if ((type) && (!strcmp(type, "elm_widget")))
12 type = elm_object_widget_type_get(event_info);
13 printf("Evas_Object focus in: %p %s\n", event_info, type);
17 _focus_out(void *data __UNUSED__, Evas *e __UNUSED__, void *event_info)
19 const char *type = evas_object_type_get(event_info);
20 if ((type) && (!strcmp(type, "elm_widget")))
21 type = elm_object_widget_type_get(event_info);
22 printf("Evas_Object focus out: %p %s\n", event_info, type);
26 _focus_obj(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
28 Evas_Object *newfocus = data;
29 const char *type = evas_object_type_get(newfocus);
30 if ((type) && (!strcmp(type, "elm_widget")))
31 type = elm_object_widget_type_get(newfocus);
32 printf("elm_object_focus_set(%p, EINA_TRUE) %s\n", newfocus, type);
33 elm_object_focus_set(newfocus, EINA_TRUE);
37 _focus_layout_part(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
39 Evas_Object *ed = elm_layout_edje_get(data);
41 Evas_Object *newfocus = (Evas_Object *)edje_object_part_object_get(ed, "sky");
42 const char *type = evas_object_type_get(newfocus);
43 printf("evas_object_focus_set(%p, 1) %s\n", newfocus, type);
44 evas_object_focus_set(newfocus, EINA_TRUE);;
49 test_focus2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
51 Evas_Object *win, *bg, *bx, *ly, *bt, *en, *bt1;
54 win = elm_win_add(NULL, "focus2", ELM_WIN_BASIC);
55 elm_win_title_set(win, "Focus2");
56 elm_win_autodel_set(win, EINA_TRUE);
57 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
59 evas_event_callback_add
60 (evas_object_evas_get(win), EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
62 evas_event_callback_add
63 (evas_object_evas_get(win), EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
67 elm_win_resize_object_add(win, bg);
68 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
71 bx = elm_box_add(win);
72 elm_win_resize_object_add(win, bx);
73 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
76 #define PARENT bx /* this is broken, but should work */
79 en = elm_entry_add(PARENT);
80 elm_entry_scrollable_set(en, EINA_TRUE);
81 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
82 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
83 elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
84 elm_entry_entry_set(en, "Scrolled Entry that should get focus");
85 elm_entry_single_line_set(en, 1);
87 elm_box_pack_end(bx, en);
89 bt = elm_button_add(PARENT);
90 elm_object_text_set(bt, "Give focus to scrolled entry");
91 evas_object_smart_callback_add(bt, "clicked", _focus_obj, en);
92 elm_box_pack_end(bx, bt);
95 ly = elm_layout_add(PARENT);
96 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
97 elm_layout_file_set(ly, buf, "layout");
98 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
99 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
100 elm_box_pack_end(bx, ly);
101 evas_object_show(ly);
103 bt1 = bt = elm_button_add(ly);
104 elm_object_text_set(bt, "Button 1");
105 elm_layout_content_set(ly, "element1", bt);
107 en = elm_entry_add(ly);
108 elm_entry_scrollable_set(en, EINA_TRUE);
109 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
110 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
111 elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
112 elm_entry_entry_set(en, "Scrolled Entry that should get focus");
113 elm_entry_single_line_set(en, 1);
114 elm_layout_content_set(ly, "element2", en);
116 bt = elm_button_add(ly);
117 elm_object_text_set(bt, "Button 2");
118 elm_layout_content_set(ly, "element3", bt);
120 bt = elm_button_add(PARENT);
121 elm_object_text_set(bt, "Give focus to layout");
122 evas_object_smart_callback_add(bt, "clicked", _focus_obj, ly);
123 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
124 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
125 elm_box_pack_end(bx, bt);
126 evas_object_show(bt);
128 bt = elm_button_add(PARENT);
129 elm_object_text_set(bt, "Give focus to layout part");
130 evas_object_smart_callback_add(bt, "clicked", _focus_layout_part, ly);
131 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
132 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
133 elm_box_pack_end(bx, bt);
134 evas_object_show(bt);
136 bt = elm_button_add(PARENT);
137 elm_object_text_set(bt, "Give focus to layout 'Button 1'");
138 evas_object_smart_callback_add(bt, "clicked", _focus_obj, bt1);
139 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
140 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
141 elm_box_pack_end(bx, bt);
142 evas_object_show(bt);
144 bt = elm_button_add(PARENT);
145 elm_object_text_set(bt, "Give focus to layout 'Entry'");
146 evas_object_smart_callback_add(bt, "clicked", _focus_obj, en);
147 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
148 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
149 elm_box_pack_end(bx, bt);
150 evas_object_show(bt);
152 evas_object_resize(win, 400, 400);
153 evas_object_show(win);