Re: gtk widget events (was: gtk_widget_set_name)



By default the drawing area isn't set up to receive button press events.
You have to explicitely change this by adding a call to:

   $drawingarea->set(events=>['button-press-mask']);

after its construction.

Then your program works just fine.

Regards,

On Mon, May 27, 2002 at 12:09:40AM +0200, Riswick, J.G.A. van wrote:
 
HI!

Yes you are right, thanks. In the meantime, I managed
to locate the manpage (Gtk::reference) and also found it 
there.         

Some time ago, I wrote a gtk program and now I'm trying
to convert it to gtk-perl. I stumbeled upon something that
I can't get to work. In my gtk program I connected a signal
handler to a drawing area like this:

            gtk_signal_connect
               (GTK_OBJECT(drawingarea), "event",
                   (GtkSignalFunc)area_event, (gpointer)drawingarea);

Now I'm trying to do the same using gtk-perl (sample below). The
callback function seems to get called, but filtering out the 
button_press event doesn't work. does anyone know what I'm doing
wrong?

jos


---------


#!/usr/bin/perl -w

use Gtk;
init Gtk;

$win = new Gtk::Window;
$win->set_usize(300,200);
$win->show_all;

$drawingarea = new Gtk::DrawingArea();
$drawingarea->show();
$win->add($drawingarea);
$drawingarea->signal_connect('event' , \&cb );

sub cb {

   my ( $widget, $data, $event ) = @_; 

 if ( ( defined( $event->{'type'} ) ) and
      ( $event->{'type'} eq 'button_press' ) )
   {
        $win->set_title('right');
     if ( $event->{'button'} == 3 )
       {
        $win->set_title('right');
       }
     else
       {
        $win->set_title('left');
       }
   }

  return 0;

}

main Gtk;



-----Original Message-----
From: Dermot Musgrove
To: Riswick, J.G.A. van
Cc: 'gtk-perl-list gnome org'
Sent: 5/26/2002 6:38 PM
Subject: Re: gtk_widget_set_name

"Riswick, J.G.A. van" wrote:

HI

Is it possible to access the function gtk_widget_set_name()
using gtk-perl? This lets the user link styles in the gtkrc
file to a widget.
Hi, I reckon so - Gtk::Widget->set_name() so for instance:

    $clist->set_name('New name');

regards, Dermot

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]