Re: signals for canvas items

Hi Daniel,

It should work. You can also do something like:

    my $card_group = 
                               "x", $cx-50,
                               "y", $cy-50,
                               "signal::event" => [\&move_card_cb]

(Taken from my abc-blocks program. See:

In the callback you then have to test the type of the event and act 
according to it. The following is also from abc-blocks:

    sub move_card_cb {
        my($item, $event) = @_;

        if ($event->{type} eq "button_press") {
            if ($event->{button} eq '1') {
                $last_cx = $event->{x};
                $last_cy = $event->{y};

            } elsif ($event->{button} eq '3') {
        elsif ($event->{type} eq "motion_notify") {
            if ($dragging) {
                my $new_x = $event->{x};
                my $new_y = $event->{y};


                $last_cx = $new_x;
                $last_cy = $new_y;
        elsif ($event->{type} eq "button_release") {
            if ($event->{button} eq '1') {

I hope this helps.


On Sat, Apr 27, 2002 at 11:11:31PM -0400, Daniel Carrera wrote:

I wish to signal_connect() events for canvas items.  However that doesn't
work.  I have looked all over the documentation for something like this
but without success.

What I would like to do is essentially:

$rectangle = $group->new($Group,"Gnome::CanvasRect",...);


But this doesn't work.

Does anyone know how you would achieve this effect?

Thanks a lot,

gtk-perl-list mailing list
gtk-perl-list gnome org

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