[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-perl
Subject: Re: [Kde-perl] canvas()->collisions ???
From: Germain Garand <germain () ebooksfrance ! org>
Date: 2003-04-15 21:24:14
[Download RAW message or body]
Le Dimanche 13 Avril 2003 16:44, Foo Bar a écrit :
> On Sun, 13 Apr 2003 17:12:26 +0100
> can you give me an example for my problem ?
> here is the code, i will move the rectange in my canvas with the mouse ...
>
> thanks for your time and patience ;)
>
[...]
> sub mouseMoveEvent {
> my $e = shift;
> my $pos = $e->pos();
>
> print $pos->x." : ".$pos->y."\n";
>
> if ( ??? ) {
Oh I see... you don't care about collisions between objects, but with a pixel
position...
mmmh, I'm afraid you'll need to checkout the CVS if you want to do it that
way.
The new QCanvasItemList marshaller will give you a reference to a Perl array
holding all the CanvasItem.
e.g:
$ar = canvas->collisions( Qt::point( 100, 100));
for( @$ar )
{
$_->moveBy(10,10);
....
}
(beware that you must recompile both PerlQt and Smoke to activate the new
marshallers.. so add --enable-smoke to the initial configuration line)
Otherwise, there might be other ways to do that, I dunno.
Maybe reimplementing also mousePressEvent()/mouseReleaseEvent() so that you
know when the event really begins/stops... record old mouse position from
there and record which CanvasItem is concerned (find this through
CanvasItem's x() y() width() height() )
then in mouseMoveEvent, move concerned item by the difference between old
mouse coordinates.
Germain
> this->{items}->{rect}->move($pos->x, $pos->y);
> this->{items}->{canvas}->update();
> } else {
> print "event not in rect\n";
> }
> }
>
>
> 1;
>
> package main;
> use myItem;
> my $a = Qt::Application(\@ARGV);
> my $w = myItem;
> $a->setMainWidget($w);
> $w->show;
> exit $a->exec;
>
>
>
>
>
> cu
_______________________________________________
Kde-perl mailing list
Kde-perl@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-perl
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic