Re: emit_stop_by_name

From: Date: Fri, 27 Oct 2006 11:27:22 +0000
Subject: Re: emit_stop_by_name
References: 1 2 3 4 5  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-7381@lists.php.net to get a copy of this message
kksou wrote:
I have done some trial and errors, and managed to get the same effect in php-gtk2 by capturing 'key-press-event' in $windows and then manually insert the characters into the GtkEntry. Though the effect is the same, the solution, if emit_stop_by_name() is available, would be more straightforward.
I played around with your example and came up with the following. You don't have to manually insert the characters and the filter works even though the logic of the if() statement may seem "backwards." Other than that, it's pretty straightforward, IMHO. Hope this helps. <?php function onInsert($widget, $event) { $result = false; $character = chr($event->keyval); if(!preg_match("/[0-9a-fA-F]/", $character)) {
       $result = true;
} return($result); } // onInsert() $entry = new GtkEntry(); $entry->connect('key-press-event', 'onInsert'); $window = new GtkWindow(); $window->set_size_request(400, 200); $window->connect_simple('destroy', array('Gtk','main_quit')); $window->connect('destroy', array('Gtk','main_quit')); $window->add($entry); $window->show_all(); Gtk::main(); ?> -Ron T.

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