kuuko pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=75ee95a7d66df69ae6696e89b728b8f7efec9962

commit 75ee95a7d66df69ae6696e89b728b8f7efec9962
Author: Kai Huuhko <[email protected]>
Date:   Tue Nov 26 02:37:46 2013 +0200

    Elementary: Improve input event example.
    
     - prevent focusing the log entry or the clear button widgets
     - move log entry widgets cursor to end when it changes
     - set weight size hints to allocate more space for log entry widget
     - clarify the output messages
---
 examples/elementary/test_input_events.py | 39 +++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/examples/elementary/test_input_events.py 
b/examples/elementary/test_input_events.py
index 8300497..4b1a8e3 100644
--- a/examples/elementary/test_input_events.py
+++ b/examples/elementary/test_input_events.py
@@ -3,6 +3,7 @@
 
 from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
 from efl import elementary
+
 from efl.elementary.box import Box
 from efl.elementary.button import Button
 from efl.elementary.entry import Entry, utf8_to_markup
@@ -15,6 +16,9 @@ FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
 def filter_cb(obj, text, data):
     return None
 
+def changed_cb(obj):
+    obj.cursor_end_set()
+
 def events_cb(obj, src, event_type, event, data):
 
     entry = data
@@ -23,23 +27,24 @@ def events_cb(obj, src, event_type, event, data):
     append(utf8_to_markup(
         "Obj: %r\n\nSrc: %r\n\nEvent: %s" % (obj, src, event)
         ))
+    append("<br><br>Modifiers:<br>")
+    append(utf8_to_markup(
+        "Control: %s Shift: %s Alt: %s" % (
+            event.modifier_is_set("Control"),
+            event.modifier_is_set("Shift"),
+            event.modifier_is_set("Alt")
+            )
+        ))
 
     if event_type == EVAS_CALLBACK_KEY_UP:
-        append("<br><br>Modifiers:<br>")
-        append(utf8_to_markup(
-            "Control: %s Shift: %s Alt: %s" % (
-                event.modifier_is_set("Control"),
-                event.modifier_is_set("Shift"),
-                event.modifier_is_set("Alt")
-                )
-            ))
-        append("<br><br>This event was handled so it won't propagate to 
window.<br>")
+        append("<br><br>This event was handled so it won't propagate to a 
parent of Obj.<br><br>")
         
append("---------------------------------------------------------------")
         append("<br><br>")
 
         return True
 
-    
append("<br>---------------------------------------------------------------")
+    append("<br><br>This event was not handled so it will propagate to a 
parent of Obj if it has one.<br><br>")
+    append("---------------------------------------------------------------")
     append("<br><br>")
 
     return False
@@ -53,21 +58,23 @@ def elm_input_events_clicked(obj, item=None):
     win.resize_object_add(box)
     box.show()
 
-    entry = Entry(win, scrollable=True,
-        size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
+    entry = Entry(win, scrollable=True, size_hint_align=FILL_BOTH,
+        size_hint_weight=(1.0, 0.2))
     entry.text = (
         "This example will show how Elementary input events are handled. "
         "Typing in this entry will log in the entry box below all events "
         "caught by event handlers set to this Entry widget and its parent, "
-        "the Window widget."
+        "the Window widget. Key up events are checked for in the callback "
+        "and won't propagate to a parent widget."
         )
     entry.show()
 
-    log_entry = Entry(win, editable=False, scrollable=True,
-        size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
+    log_entry = Entry(win, editable=False, scrollable=True, focus_allow=False,
+        size_hint_align=FILL_BOTH, size_hint_weight=(1.0, 0.8))
+    log_entry.callback_changed_add(changed_cb)
     log_entry.show()
 
-    btn = Button(win, text="Clear log")
+    btn = Button(win, text="Clear log", focus_allow=False)
     btn.callback_clicked_add(lambda x: setattr(log_entry, "entry", ""))
     btn.show()
 

-- 


Reply via email to