detect typing end on GtkEntry

From: Date: Sat, 19 Apr 2003 18:19:53 +0000
Subject: detect typing end on GtkEntry
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-3246@lists.php.net to get a copy of this message
Hello, First, sorry for my poor English. Mi question is: ¿is there a way to know when a user has finished typing on a gtkEntry? I'm currently using the changed signal to make a query against a huge database, and that gets a lot of time. I wonder if i can detect if there has been another change to the entry, and then doing the query with the new entry text. I've been trying the next code at the entry_changed function: if (gtk::events_pending()) { gtk::main_iteration(); } else { DO_THE_QUERY } But that way i doesn't control the events of the gtkentry, but all the events. If another event comes, the query doesn't run and i get no more _changed events. I've benn trying to sleep a bit the function, get the contents of the entry and compare it; if the are equal, i go with the query like this: (code from the php.net manual) $text = $entry->get_text(); $usec=1000; $start = gettimeofday(); $hacer_query = true; do { while (gtk::events_pending()) gtk::main_iteration(); // The loop refreshes $txtbox2 = $glade_app->get_widget("entry_apellido"); $text2 = $txtbox2->get_text(); if ($text != $text2) { $do_query = false; } $stop = gettimeofday(); $timePassed = 1000000 * ($stop['sec'] - $start['sec']) + $stop['usec'] - $start['usec']; } while ($timePassed < $usec); if ($do_query) DO_THE_QUERY And that works except that the entry makes odd things, like if i write four letters (say 'help') it shows 'hple', like if the cursor weren't too fast and were always after the first letter. Well, thats all. Thanks in advance! -- ------------------------------------------------------------------------ C/ Isabel de Farnesio Nº 20 – Local 4 || C.P. 28660 – Boadilla del Monte (Madrid) Teléfono 91 632 69 50 – Fax 91 632 69 18 www.mainsip.com <http://www.mainsip.com> – info@mainsip.com <mailto:info@mainsip.com>

« previous php.gtk.general (#3246) next »