entry: add elm_entry_select_allow_set/get APIs 55/69755/2
authorYoungbok Shin <youngb.shin@samsung.com>
Mon, 16 May 2016 13:05:08 +0000 (22:05 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Mon, 16 May 2016 13:16:59 +0000 (22:16 +0900)
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

Change-Id: I433ec3b894033b88a4be1364bab6663d3d187a57

src/lib/elm_entry.c
src/lib/elm_entry.eo
src/lib/elm_widget_entry.h

index bcab530..3961de8 100644 (file)
@@ -1609,8 +1609,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_object_part_text_select_allow_set
+        (sd->entry_edje, "elm.text", EINA_TRUE);
+   else
+     edje_object_part_text_select_allow_set
+        (sd->entry_edje, "elm.text", EINA_FALSE);
 
    elm_object_text_set(obj, t);
    eina_stringshare_del(t);
@@ -2127,6 +2131,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");
 
@@ -2417,7 +2423,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
@@ -4715,6 +4721,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;
    /////////////////////////////////////////////////////////////////
@@ -6592,6 +6599,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_object_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)
 {
index f13e96a..8867a7e 100644 (file)
@@ -632,6 +632,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;
index f2108e6..2be0bcd 100644 (file)
@@ -122,6 +122,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;