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_scrolled_entry_add(PARENT);
79 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
80 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
81 elm_scrolled_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
82 elm_scrolled_entry_entry_set(en, "Scrolled Entry that should get focus");
83 elm_scrolled_entry_single_line_set(en, 1);
85 elm_box_pack_end(bx, en);
87 bt = elm_button_add(PARENT);
88 elm_button_label_set(bt, "Give focus to scrolled entry");
89 evas_object_smart_callback_add(bt, "clicked", _focus_obj, en);
90 elm_box_pack_end(bx, bt);
93 ly = elm_layout_add(PARENT);
94 elm_layout_file_set(ly, PACKAGE_DATA_DIR"/objects/test.edj", "layout");
95 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
96 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
97 elm_box_pack_end(bx, ly);
100 bt1 = bt = elm_button_add(ly);
101 elm_button_label_set(bt, "Button 1");
102 elm_layout_content_set(ly, "element1", bt);
104 en = elm_scrolled_entry_add(ly);
105 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
106 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
107 elm_scrolled_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
108 elm_scrolled_entry_entry_set(en, "Scrolled Entry that should get focus");
109 elm_scrolled_entry_single_line_set(en, 1);
110 elm_layout_content_set(ly, "element2", en);
112 bt = elm_button_add(ly);
113 elm_button_label_set(bt, "Button 2");
114 elm_layout_content_set(ly, "element3", bt);
116 bt = elm_button_add(PARENT);
117 elm_button_label_set(bt, "Give focus to layout");
118 evas_object_smart_callback_add(bt, "clicked", _focus_obj, ly);
119 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
120 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
121 elm_box_pack_end(bx, bt);
122 evas_object_show(bt);
124 bt = elm_button_add(PARENT);
125 elm_button_label_set(bt, "Give focus to layout part");
126 evas_object_smart_callback_add(bt, "clicked", _focus_layout_part, ly);
127 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
128 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
129 elm_box_pack_end(bx, bt);
130 evas_object_show(bt);
132 bt = elm_button_add(PARENT);
133 elm_button_label_set(bt, "Give focus to layout 'Button 1'");
134 evas_object_smart_callback_add(bt, "clicked", _focus_obj, bt1);
135 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
136 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
137 elm_box_pack_end(bx, bt);
138 evas_object_show(bt);
140 bt = elm_button_add(PARENT);
141 elm_button_label_set(bt, "Give focus to layout 'Entry'");
142 evas_object_smart_callback_add(bt, "clicked", _focus_obj, en);
143 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
144 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
145 elm_box_pack_end(bx, bt);
146 evas_object_show(bt);
148 evas_object_resize(win, 400, 400);
149 evas_object_show(win);