diff options
author | Toshio Kuratomi <a.badger@gmail.com> | 2017-01-21 13:03:40 -0800 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2017-01-21 13:03:40 -0800 |
commit | cad6c144bf9940aa672611a36f2174655c579af7 (patch) | |
tree | b8f1ebd948d60be3b705c2f23df33cffdc0e948d /urwid | |
parent | fee50e77e85fb0fc5f7d664ae13c0e139d711a00 (diff) | |
download | urwid-cad6c144bf9940aa672611a36f2174655c579af7.tar.gz |
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
Diffstat (limited to 'urwid')
-rw-r--r-- | urwid/widget.py | 2 |
1 files changed, 1 insertions, 1 deletions
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): |