aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--efl/elementary/entry.pxi29
-rw-r--r--efl/elementary/entry_cdef.pxi1
-rw-r--r--examples/elementary/test_entry.py24
3 files changed, 54 insertions, 0 deletions
diff --git a/efl/elementary/entry.pxi b/efl/elementary/entry.pxi
index 8e82210..628b89c 100644
--- a/efl/elementary/entry.pxi
+++ b/efl/elementary/entry.pxi
@@ -645,6 +645,23 @@ cdef class Entry(LayoutClass):
"""This selects all text within the entry."""
elm_entry_select_all(self.obj)
+ property select_region:
+ """The selected region within the entry.
+
+ :type: 2 ints tuple (start, end)
+
+ .. versionadded: 1.18
+
+ """
+ def __get__(self):
+ cdef int start, end
+ elm_entry_select_region_get(self.obj, &start, &end)
+ return (start, end)
+ def __set__(self, value):
+ cdef int start, end
+ start, end = value
+ elm_entry_select_region_set(self.obj, start, end)
+
def select_region_set(self, int start, int end):
"""This selects a region of text within the entry.
@@ -657,6 +674,18 @@ cdef class Entry(LayoutClass):
"""
elm_entry_select_region_set(self.obj, start, end)
+ def select_region_get(self):
+ """Get the current position of the selection cursors in the entry.
+
+ :return: the 2 ints tuple (start, end)
+ :rtype: tuple
+
+ .. versionadded: 1.18
+
+ """
+ cdef int start, end
+ elm_entry_select_region_get(self.obj, &start, &end)
+ return (start, end)
def cursor_next(self):
"""This moves the cursor one place to the right within the entry.
diff --git a/efl/elementary/entry_cdef.pxi b/efl/elementary/entry_cdef.pxi
index a46dbb8..66d7f38 100644
--- a/efl/elementary/entry_cdef.pxi
+++ b/efl/elementary/entry_cdef.pxi
@@ -173,6 +173,7 @@ cdef extern from "Elementary.h":
void elm_entry_select_none(Evas_Object *obj)
void elm_entry_select_all(Evas_Object *obj)
void elm_entry_select_region_set(Evas_Object *obj, int start, int end)
+ void elm_entry_select_region_get(Evas_Object *obj, int *start, int *end)
Eina_Bool elm_entry_cursor_next(Evas_Object *obj)
Eina_Bool elm_entry_cursor_prev(Evas_Object *obj)
Eina_Bool elm_entry_cursor_up(Evas_Object *obj)
diff --git a/examples/elementary/test_entry.py b/examples/elementary/test_entry.py
index b4c43bb..f1693b7 100644
--- a/examples/elementary/test_entry.py
+++ b/examples/elementary/test_entry.py
@@ -52,6 +52,12 @@ def my_entry_bt_5(chk):
def my_entry_anchor_test(obj, anchor, en, *args, **kwargs):
en.entry_insert("ANCHOR CLICKED")
+def my_entry_bt_6(bt, en):
+ en.select_region = (3, 10)
+
+def my_entry_bt_7(bt, en):
+ print("Sel region: ", en.select_region)
+
def entry_clicked(obj, item=None):
win = StandardWindow("entry", "Entry", autodel=True)
@@ -108,6 +114,24 @@ def entry_clicked(obj, item=None):
bx.pack_end(bx2)
bx2.show()
+ bx2 = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ,
+ size_hint_align=FILL_BOTH)
+
+ bt = Button(win, text="Sel region set", size_hint_weight=EXPAND_HORIZ,
+ size_hint_align=FILL_BOTH)
+ bt.callback_clicked_add(my_entry_bt_6, en)
+ bx2.pack_end(bt)
+ bt.show()
+
+ bt = Button(win, text="Sel region get", size_hint_weight=EXPAND_HORIZ,
+ size_hint_align=FILL_BOTH)
+ bt.callback_clicked_add(my_entry_bt_7, en)
+ bx2.pack_end(bt)
+ bt.show()
+
+ bx.pack_end(bx2)
+ bx2.show()
+
en.focus_set(True)
win.show()