Blocking signal_changed() in Entry for real
- From: Yann Leydier <yann leydier info>
- To: gtkmm-list gnome org
- Subject: Blocking signal_changed() in Entry for real
- Date: Wed, 08 Feb 2012 12:42:27 +0100
Hi,
I'd like to create an auto-completion process with an Entry. As image
processing is involved it's very impractical to use the Completion class.
So, I connect to the "changed" signal, set the new text and select the
end of the text so that the user may continue to type and overwrite the
auto-completion.
However, despite blocking the signal, the callback is called twice. It
acts like the set_text() method is asynchronous. Is there a way to
really block the "changed" signal till the Entry is really updated?
Thanks,
yann
Sample code:
Cell::Cell()
{
on_text_changed_connection =
signal_changed().connect(sigc::mem_fun(this, &Cell::on_text_changed));
}
void Cell::on_text_changed()
{
on_text_changed_connection.block();
std::cout << "blocked" << std::endl;
int cursor = (int)get_text().size();
set_text(call_to_custom_competion());
set_position(cursor);
select_region(cursor, (int)get_text().size());
std::cout << "select from " << cursor << " to " << get_text().size() <<
std::endl;
std::cout << "completed" << std::endl;
on_text_changed_connection.unblock();
std::cout << "unblocked" << std::endl;
}
Output when erasing the last character of a text of size 12:
blocked
select from 11 to 12
completed
unblocked
blocked
select from 12 to 12
completed
unblocked
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]