From cad6c144bf9940aa672611a36f2174655c579af7 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sat, 21 Jan 2017 13:03:40 -0800 Subject: Do not emit change until after text is updated Sometimes an Edit's change handler wants to edit the text that has just been entered. For instance, if the handler does validation, it may want to immediately highlight or prevent invalid entries from being shown. This is not possible if the change signal is emitted before the internal text data is updated as the update will overwrite anything that the change handler performed. Emitting the change event after the update has been performed allows for changes to be made. Fixes #212 --- urwid/widget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'urwid') diff --git a/urwid/widget.py b/urwid/widget.py index 661e7ed..a3e39d8 100644 --- a/urwid/widget.py +++ b/urwid/widget.py @@ -1354,10 +1354,10 @@ class Edit(Text): """ text = self._normalize_to_caption(text) self.highlight = None - self._emit("change", text) self._edit_text = text if self.edit_pos > len(text): self.edit_pos = len(text) + self._emit("change", text) self._invalidate() def get_edit_text(self): -- cgit v1.2.1