Handling Return Key Presses
| From: | Anant Narayanan | Date: | Sat, 19 Nov 2005 06:01:53 +0000 |
| Subject: | Handling Return Key Presses | ||
| Groups: | php.gtk.dev | ||
| Request: | Send a blank email to php-gtk-dev+get-2076@lists.php.net to get a copy of this message | ||
Hi all!
Check out this program as an example for the constructor for GtkEntry.
There is no problem when the button is 'clicked', the text is properly
echoed. However when you use the 'return' key:
Warning: PHP-GTK internal error: unsupported type (null) in
F:\xampp\htdocs\GTKDoc\my-php-gtk-doc\examples\reference\gtk\gtkentry\constructor.phpw
on line 42
Warning: Could not convert return value of signal callback 'get_input' to
'(null)' in
F:\xampp\htdocs\GTKDoc\my-php-gtk-doc\examples\reference\gtk\gtkentry\cons
tructor.phpw on line 42
Is there something wrong with the program or is there a seperate way to
"handle return keys".
Here's the program: (Example for GtkEntry,
/examples/reference/gtk/gtkentry/constructor.phpw, present in
http://www.kix.in/php-gtk-doc.tar)
<?php
/* Checking for PHP-GTK 2 Module */
if(!class_exists('gtk')) {
die('Please load the PHP-GTK 2 module in your php.ini');
}
/* Function to retrieve text from GtkEntry and Print it */
function get_input($entry) {
$input=$entry->get_text();
echo "$input\n";
$entry->grab_focus();
$entry->set_text("");
}
/* Setting up the Window
Note the usage of connect_simple()
instead of deprecated connect_object() */
$window = &new GtkWindow();
$window->set_position(GTK_WIN_POS_CENTER);
$window->connect_simple('destroy', array('gtk', 'main_quit'));
/* Adding a box to the Window to allow more than one Child */
$box = &new GtkVBox();
$window->add($box);
/* Adding the GtkEntry widget and connecting
it to the callback function: get_text() */
$entry = &new GtkEntry();
$entry->connect('activate', 'get_input');
$box->add($entry);
/* Adding a GtkButton to the box and use connect_simple() so that it
will pass the GtkEntry to the callback function when it is clicked */
$button = &new GtkButton('Click Me to echo input!');
$button->connect_simple('clicked', 'get_input', $entry);
$box->add($button);
/* Display everything and start the main loop */
$box->show_all();
$window->show_all();
gtk::main();
?>
P.S. - Sorry about my last post at php-gtk-doc. I understand that all of you
are extremely busy. I was just wondering whether to continue doccing other
classes without any feedback on my first posting. :-)
Thanks and Regards,
--
Anant Narayanan
-------------------------
Find Freedom!
http://www.kix.in/