entry: add elm_entry_select_allow_set/get APIs
Summary: There is no way to allow/deny the text selection feature. It is only controlled by disabled state. But, some UX does not want to allow the text selection on editable entry widget. @feature Test Plan: Run the following test case. You can see "Select Allow" check box. elementary_test -to entry Reviewers: tasn, herdsman, cedric, thiepha Reviewed By: thiepha Subscribers: jpeg Differential Revision: https://phab.enlightenment.org/D3934
This commit is contained in:
parent
782f28e9a1
commit
e49d84f057
|
@ -94,10 +94,22 @@ changed_cb1(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|||
printf("ck2 %p is now %i\n", ck, elm_check_state_get(ck));
|
||||
}
|
||||
|
||||
static void
|
||||
select_allow_check_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *en = data;
|
||||
elm_entry_select_allow_set(en, elm_check_state_get(obj));
|
||||
|
||||
if (elm_check_state_get(obj))
|
||||
printf("Entry %p is now selectable.\n", en);
|
||||
else
|
||||
printf("Entry %p is now unselectable.\n", en);
|
||||
}
|
||||
|
||||
void
|
||||
test_entry(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *bx, *bx2, *bt, *en, *ck;
|
||||
Evas_Object *win, *bx, *bx2, *bx3, *bt, *en, *ck;
|
||||
char buf[4096];
|
||||
|
||||
win = elm_win_util_standard_add("entry", "Entry");
|
||||
|
@ -216,13 +228,27 @@ test_entry(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_inf
|
|||
elm_object_focus_allow_set(bt, EINA_FALSE);
|
||||
evas_object_show(bt);
|
||||
|
||||
bx3 = elm_box_add(win);
|
||||
elm_box_horizontal_set(bx3, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
||||
ck = elm_check_add(win);
|
||||
elm_object_text_set(ck, "Context Menu Disable");
|
||||
evas_object_smart_callback_add(ck, "changed", changed_cb1, ck);
|
||||
elm_box_pack_end(bx, ck);
|
||||
elm_box_pack_end(bx3, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
ck = elm_check_add(win);
|
||||
elm_object_text_set(ck, "Select Allow");
|
||||
elm_check_state_set(ck, elm_entry_select_allow_get(en));
|
||||
evas_object_smart_callback_add(ck, "changed", select_allow_check_changed_cb, en);
|
||||
elm_box_pack_end(bx3, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
elm_box_pack_end(bx, bx3);
|
||||
elm_box_pack_end(bx, bx2);
|
||||
evas_object_show(bx3);
|
||||
evas_object_show(bx2);
|
||||
|
||||
evas_object_show(win);
|
||||
|
|
|
@ -862,8 +862,12 @@ _elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd)
|
|||
elm_widget_theme_object_set
|
||||
(obj, sd->entry_edje, "entry", _elm_entry_theme_group_get(obj), style);
|
||||
|
||||
edje_object_part_text_select_allow_set
|
||||
(sd->entry_edje, "elm.text", _elm_config->desktop_entry);
|
||||
if (sd->sel_allow && _elm_config->desktop_entry)
|
||||
edje_obj_part_text_select_allow_set
|
||||
(sd->entry_edje, "elm.text", EINA_TRUE);
|
||||
else
|
||||
edje_obj_part_text_select_allow_set
|
||||
(sd->entry_edje, "elm.text", EINA_FALSE);
|
||||
|
||||
elm_object_text_set(obj, t);
|
||||
eina_stringshare_del(t);
|
||||
|
@ -1383,6 +1387,8 @@ _hover_selected_cb(void *data,
|
|||
{
|
||||
ELM_ENTRY_DATA_GET(data, sd);
|
||||
|
||||
if (!sd->sel_allow) return;
|
||||
|
||||
sd->sel_mode = EINA_TRUE;
|
||||
edje_object_part_text_select_none(sd->entry_edje, "elm.text");
|
||||
|
||||
|
@ -1673,7 +1679,7 @@ _menu_call(Evas_Object *obj)
|
|||
{
|
||||
if (!sd->sel_mode)
|
||||
{
|
||||
if (!_elm_config->desktop_entry)
|
||||
if (sd->sel_allow && !_elm_config->desktop_entry)
|
||||
{
|
||||
if (!sd->password)
|
||||
elm_hoversel_item_add
|
||||
|
@ -3590,6 +3596,7 @@ _elm_entry_evas_object_smart_add(Eo *obj, Elm_Entry_Data *priv)
|
|||
priv->context_menu = EINA_TRUE;
|
||||
priv->auto_save = EINA_TRUE;
|
||||
priv->editable = EINA_TRUE;
|
||||
priv->sel_allow = EINA_TRUE;
|
||||
|
||||
priv->drop_format = ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE;
|
||||
elm_drop_target_add(obj, priv->drop_format,
|
||||
|
@ -5313,6 +5320,21 @@ _elm_entry_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Entry_
|
|||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_entry_select_allow_set(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, Eina_Bool allow)
|
||||
{
|
||||
if (sd->sel_allow == allow) return;
|
||||
sd->sel_allow = allow;
|
||||
|
||||
edje_obj_part_text_select_allow_set(sd->entry_edje, "elm.text", allow);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_entry_select_allow_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd)
|
||||
{
|
||||
return sd->sel_allow;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_entry_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
|
|
|
@ -650,6 +650,17 @@ class Elm.Entry (Elm.Layout, Elm.Interface_Scrollable, Evas.Clickable_Interface,
|
|||
return: bool;
|
||||
}
|
||||
}
|
||||
@property select_allow {
|
||||
set {
|
||||
[[Allow selection in the entry.]]
|
||||
}
|
||||
get {
|
||||
[[Returns whether selection in the entry is allowed.]]
|
||||
}
|
||||
values {
|
||||
allow: bool; [[If $allow is true, the text selection is allowed.]]
|
||||
}
|
||||
}
|
||||
cursor_prev {
|
||||
[[This moves the cursor one place to the left within the entry.]]
|
||||
return: bool;
|
||||
|
|
|
@ -109,6 +109,7 @@ struct _Elm_Entry_Data
|
|||
Eina_Bool has_text : 1;
|
||||
Eina_Bool use_down : 1;
|
||||
Eina_Bool sel_mode : 1;
|
||||
Eina_Bool sel_allow : 1;
|
||||
Eina_Bool changed : 1;
|
||||
Eina_Bool scroll : 1;
|
||||
Eina_Bool input_panel_show_on_demand : 1;
|
||||
|
|
Loading…
Reference in New Issue