From 75ee95a7d66df69ae6696e89b728b8f7efec9962 Mon Sep 17 00:00:00 2001 From: Kai Huuhko Date: Tue, 26 Nov 2013 02:37:46 +0200 Subject: [PATCH] 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("

Modifiers:
") + 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("

Modifiers:
") - 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("

This event was handled so it won't propagate to window.
") + append("

This event was handled so it won't propagate to a parent of Obj.

") append("---------------------------------------------------------------") append("

") return True - append("
---------------------------------------------------------------") + append("

This event was not handled so it will propagate to a parent of Obj if it has one.

") + append("---------------------------------------------------------------") append("

") 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()