1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>
static void
_rdg_changed_cb(void *data, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Evas_Object *bt = data;
int value = elm_radio_value_get(obj);
// set focus move policy to the test button
switch (value)
{
case 0:
elm_object_text_set(bt, "Test Button (MOUSE CLICK or KEY)");
elm_object_focus_move_policy_set(bt, ELM_FOCUS_MOVE_POLICY_CLICK);
break;
case 1:
elm_object_text_set(bt, "Test Button (MOUSE IN or KEY)");
elm_object_focus_move_policy_set(bt, ELM_FOCUS_MOVE_POLICY_IN);
break;
case 2:
elm_object_text_set(bt, "Test Button (KEY ONLY)");
elm_object_focus_move_policy_set(bt, ELM_FOCUS_MOVE_POLICY_KEY_ONLY);
break;
default:
break;
}
}
void
test_focus_object_policy(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *win, *fr, *fr2, *bx, *fr_bx, *bt, *test_bt, *lbl, *rdg, *rd;
win = elm_win_util_standard_add("focus-object-policy", "Focus Object Policy");
elm_win_autodel_set(win, EINA_TRUE);
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
elm_win_focus_highlight_animate_set(win, EINA_TRUE);
elm_win_focus_highlight_style_set(win, "glow");
fr = elm_frame_add(win);
evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, fr);
elm_object_style_set(fr, "pad_large");
evas_object_show(fr);
bx = elm_box_add(fr);
elm_object_content_set(fr, bx);
evas_object_show(bx);
/* frame 1 for normal buttons */
{
fr2 = elm_frame_add(bx);
evas_object_size_hint_weight_set(fr2, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(fr2, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_text_set(fr2, "Focusable Buttons");
elm_box_pack_end(bx, fr2);
evas_object_show(fr2);
fr_bx = elm_box_add(fr2);
elm_object_content_set(fr2, fr_bx);
evas_object_show(fr_bx);
bt = elm_button_add(fr_bx);
elm_object_text_set(bt, "Button 1");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(fr_bx, bt);
evas_object_show(bt);
elm_object_focus_set(bt, EINA_TRUE);
bt = elm_button_add(fr_bx);
elm_object_text_set(bt, "Button 2");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(fr_bx, bt);
evas_object_show(bt);
// a button to test focus object policy
test_bt = elm_button_add(fr_bx);
elm_object_text_set(test_bt, "Test Button (MOUSE CLICK or KEY)");
evas_object_size_hint_weight_set(test_bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(test_bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(fr_bx, test_bt);
evas_object_show(test_bt);
elm_object_focus_move_policy_set(bt, ELM_FOCUS_MOVE_POLICY_CLICK);
bt = elm_button_add(fr_bx);
elm_object_text_set(bt, "Button 4");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(fr_bx, bt);
evas_object_show(bt);
}
/* a frame 2 for the test button */
{
fr2 = elm_frame_add(bx);
evas_object_size_hint_weight_set(fr2, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(fr2, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_text_set(fr2, "Focus Options for a TEST button");
elm_box_pack_end(bx, fr2);
evas_object_show(fr2);
fr_bx = elm_box_add(fr2);
elm_object_content_set(fr2, fr_bx);
evas_object_show(fr_bx);
lbl = elm_label_add(fr_bx);
evas_object_size_hint_weight_set(lbl, EVAS_HINT_EXPAND, 0);
elm_object_text_set(lbl, "This focus option will be applied only for a TEST button. <br/>The focus policies of other buttons will be remain in MOUSE CLICK status.");
elm_box_pack_end(fr_bx, lbl);
evas_object_show(lbl);
// radios to select focus object policy
rd = elm_radio_add(fr_bx);
elm_radio_state_value_set(rd, 0);
evas_object_size_hint_align_set(rd, 0.0, 0.5);
elm_object_text_set(rd, "Focus Move Pollicy Mouse Click");
elm_box_pack_end(fr_bx, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, test_bt);
rdg = rd;
rd = elm_radio_add(fr_bx);
elm_radio_state_value_set(rd, 1);
elm_radio_group_add(rd, rdg);
evas_object_size_hint_align_set(rd, 0.0, 0.5);
elm_object_text_set(rd, "Focus Move Policy Mouse In");
elm_box_pack_end(fr_bx, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, test_bt);
rd = elm_radio_add(fr_bx);
elm_radio_state_value_set(rd, 2);
elm_radio_group_add(rd, rdg);
evas_object_size_hint_align_set(rd, 0.0, 0.5);
elm_object_text_set(rd, "Focus Move Pollicy Key Only");
elm_box_pack_end(fr_bx, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, test_bt);
}
evas_object_resize(win, 320, 320);
evas_object_show(win);
}
|