From 8637f7edbd9b6722797746ea3f4abc3e2015b9b1 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Sun, 29 Apr 2012 20:48:43 +0000 Subject: [PATCH] Add a NOTIFY_MODIFIED event for the text. It fires when the text in the box is modified. Note the implementation is not tested heavily. The code is used to experiment with a different approach of the implementation of a listbox. --- src/gui/widgets/text.cpp | 4 ++++ src/gui/widgets/text.hpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/gui/widgets/text.cpp b/src/gui/widgets/text.cpp index a0429510020..c007a527c23 100644 --- a/src/gui/widgets/text.cpp +++ b/src/gui/widgets/text.cpp @@ -157,6 +157,7 @@ void ttext_::paste_selection(const bool mouse) update_canvas(); set_dirty(); + fire(event::NOTIFY_MODIFIED, *this, NULL); } void ttext_::set_selection_start(const size_t selection_start) @@ -241,6 +242,7 @@ void ttext_::handle_key_backspace(SDLMod /*modifier*/, bool& handled) } else if(selection_start_){ delete_char(true); } + fire(event::NOTIFY_MODIFIED, *this, NULL); } void ttext_::handle_key_delete(SDLMod /*modifier*/, bool& handled) @@ -253,6 +255,7 @@ void ttext_::handle_key_delete(SDLMod /*modifier*/, bool& handled) } else if (selection_start_ < text_.get_length()) { delete_char(false); } + fire(event::NOTIFY_MODIFIED, *this, NULL); } void ttext_::handle_key_default( @@ -263,6 +266,7 @@ void ttext_::handle_key_default( if(unicode >= 32 && unicode != 127) { handled = true; insert_char(unicode); + fire(event::NOTIFY_MODIFIED, *this, NULL); } } diff --git a/src/gui/widgets/text.hpp b/src/gui/widgets/text.hpp index 37029576fb3..ceefc8c9416 100644 --- a/src/gui/widgets/text.hpp +++ b/src/gui/widgets/text.hpp @@ -31,6 +31,12 @@ namespace gui2 { * * All other text classes should inherit from this base class. * + * The NOTIFY_MODIFIED event is send when the text is modified. + * + * @todo Validate whether the NOTIFY_MODIFIED is always fired properly. The + * current implementation is added for some quick testing so some cases might + * be forgotten. + * * Common signal handlers: * - connect_signal_pre_key_press */