mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-11 21:17:28 +00:00
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:
parent
2f7383d94b
commit
8637f7edbd
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user