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(%p) %s\n", newfocus, type);
33 elm_object_focus(newfocus);
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;
53 win = elm_win_add(NULL, "focus2", ELM_WIN_BASIC);
54 elm_win_title_set(win, "Focus2");
55 elm_win_autodel_set(win, 1);
56 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
58 evas_event_callback_add
59 (evas_object_evas_get(win), EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
61 evas_event_callback_add
62 (evas_object_evas_get(win), EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
66 elm_win_resize_object_add(win, bg);
67 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
70 bx = elm_box_add(win);
71 elm_win_resize_object_add(win, bx);
72 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 #define PARENT bx /* this is broken, but should work */
78 en = elm_entry_add(PARENT);
79 elm_entry_scrollable_set(en, EINA_TRUE);
80 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
81 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
82 elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
83 elm_entry_entry_set(en, "Scrolled Entry that should get focus");
84 elm_entry_single_line_set(en, 1);
86 elm_box_pack_end(bx, en);
88 bt = elm_button_add(PARENT);
89 elm_button_label_set(bt, "Give focus to scrolled entry");
90 evas_object_smart_callback_add(bt, "clicked", _focus_obj, en);
91 elm_box_pack_end(bx, bt);
94 ly = elm_layout_add(PARENT);
95 elm_layout_file_set(ly, PACKAGE_DATA_DIR"/objects/test.edj", "layout");
96 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
97 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
98 elm_box_pack_end(bx, ly);
101 bt1 = bt = elm_button_add(ly);
102 elm_button_label_set(bt, "Button 1");
103 elm_layout_content_set(ly, "element1", bt);
105 en = elm_entry_add(ly);
106 elm_entry_scrollable_set(en, EINA_TRUE);
107 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
108 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
109 elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
110 elm_entry_entry_set(en, "Scrolled Entry that should get focus");
111 elm_entry_single_line_set(en, 1);
112 elm_layout_content_set(ly, "element2", en);
114 bt = elm_button_add(ly);
115 elm_button_label_set(bt, "Button 2");
116 elm_layout_content_set(ly, "element3", bt);
118 bt = elm_button_add(PARENT);
119 elm_button_label_set(bt, "Give focus to layout");
120 evas_object_smart_callback_add(bt, "clicked", _focus_obj, ly);
121 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
122 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
123 elm_box_pack_end(bx, bt);
124 evas_object_show(bt);
126 bt = elm_button_add(PARENT);
127 elm_button_label_set(bt, "Give focus to layout part");
128 evas_object_smart_callback_add(bt, "clicked", _focus_layout_part, ly);
129 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
130 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
131 elm_box_pack_end(bx, bt);
132 evas_object_show(bt);
134 bt = elm_button_add(PARENT);
135 elm_button_label_set(bt, "Give focus to layout 'Button 1'");
136 evas_object_smart_callback_add(bt, "clicked", _focus_obj, bt1);
137 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
138 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
139 elm_box_pack_end(bx, bt);
140 evas_object_show(bt);
142 bt = elm_button_add(PARENT);
143 elm_button_label_set(bt, "Give focus to layout 'Entry'");
144 evas_object_smart_callback_add(bt, "clicked", _focus_obj, en);
145 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
146 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
147 elm_box_pack_end(bx, bt);
148 evas_object_show(bt);
150 evas_object_resize(win, 400, 400);
151 evas_object_show(win);