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.
This commit is contained in:
Mark de Wever 2012-04-29 20:48:43 +00:00
parent 2f7383d94b
commit 8637f7edbd
2 changed files with 10 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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
*/