Many thanks for that.
I have tried to use tags as you suggest by adding the same tag to a number of itemsthat I was going to use as a group.
I then set the following binds where $last_tag_global contained the tag I set on the items.
$wg{Layout_Canvas}->bind($last_tag_global, '<1>', sub {&mobileStart();
+});
$wg{Layout_Canvas}->bind($last_tag_global, '<B1-Motion>', sub {&mobile
+Move();});
$wg{Layout_Canvas}->bind($last_tag_global, '<ButtonRelease-1>', sub {&
+mobileStop();});
I then used the following subroutines (which I found on another Monks thread) to select the items that had the tag, ‘jump’them onto the cursor and move them to the required position.
sub mobileStart {
my $ev = $wg{Layout_Canvas}->XEvent;
($dx_cursor, $dy_cursor) = (0 - $ev->x, 0 - $ev->y);
$wg{Layout_Canvas}->raise('current');
print "START MOVE-> $dx_cursor $dy_cursor\n";
}
sub mobileMove {
my $ev = $wg{Layout_Canvas}->XEvent;
$wg{Layout_Canvas}->move('current', $ev->x + $dx_cursor, $ev->y
++$dy_cursor);
($dx_cursor, $dy_cursor) = (0 - $ev->x, 0 - $ev->y);
print "MOVING-> $dx_cursor $dy_cursor\n";
}
sub mobileStop{&mobileMove;}
This nearly worked except that it would only move one of the items at a time and onlywhen the cursor was exactly or nearly exactly over a section (for example a side of a rectangle drawn with canvasRectangle) of the item.
What do I have to do so that I can select all of the items that have a particular tag (by placing the cursor somewhere in the 'middle' of the items that have the tag)and move them together to where I want them to be?
|