Re: GtkFixed doesn't receive button_release_event ?!

From: Date: Fri, 28 Sep 2001 10:35:26 +0000
Subject: Re: GtkFixed doesn't receive button_release_event ?!
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-164@lists.php.net to get a copy of this message
On Fri, Sep 28, 2001 at 11:32:03AM +0000, Christophe VG wrote : > // fixed2 > $fixed2 = &new GtkFixed; > $fixed->put( $fixed2, 0, 0 ); > > $button = &new GtkButton( 'Nothing' ); > $fixed2->put( $button, 25, 25 ); > > $fixed2->connect( 'button_press_event', 'on_mouse_down' ); > $fixed2->connect( 'button_release_event', 'on_mouse_up' ); Why do you connect the signals to the GtkFixed widget and not to the $button ? > This builds a window with a fixed layout with a button and another fixed > layout also with a button (just to stretch the second fixed layout). > Both the first button and the second layout are connected to the same > signal handlers. > > Pressing and releasing the mouse button on the first button gives the > expected result. Doing the same in the area where we can access the > fixed layout only returns down events. GtkFixed widget (like e.g GtkLabel) does not receive such kind of events. If you want to catch them there you will have to use another widget, GtkEventBox (put the GtkFixed into the GtkEventBox first and connect the signals to the GtkEventBox). But I think you really want to connect your handlers directly to the button, no? > Anyhow, I hope someone can point me to a solution or a reason for this > behaviour. > > While you're at it, a fewe related things ... > > 1) is there a way to get the current mouse position ? Events like 'button_press_event' pass GdkEvent object to the callback handler. GdkEvent contains this information (just use var_dump($event); to find it) > 2) are the x,y coordinates passed to the signal handler of the > button_press and release ? Yes. > 3) is there a mouse_move event ? ... The signal in question is 'motion_notify_event'; again your callback gets an GdkEvent object with the information you need. You might want to take a look at the GTK+ Tutorial [1]; most of tis information can be reused for PHP-GTK. PHP-GTK also comes with a test application called scribble.php in the test/ directory. - Markus [1] http://www.gtk.org/tutorial/ -- Markus Fischer, http://guru.josefine.at/~mfischer/ EMail: mfischer@guru.josefine.at PGP Public Key: http://guru.josefine.at/~mfischer/C2272BD0.asc PGP Fingerprint: D3B0 DD4F E12B F911 3CE1 C2B5 D674 B445 C227 2BD0 -All your scripts are belong to Zend-

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