hitTest(): best practice with multi groups (levels) selection

523 views
Skip to first unread message

Strae

unread,
Nov 23, 2012, 11:02:52 AM11/23/12
to pap...@googlegroups.com
Hello all, im using the nighty of paper.js (for the hitTest() bug on raster items) and this is my first experience with paperjs.

In my project, i have many layers (only one visible at time), and every layer have 3 groups: group_top, group_middle and group_bottom.

The top and bottom group contains only graphical elements, e.g backgrounds images and some kind of effects (shadows, lights, etc..) that should never be used for hitTest(), instead the middle group will contain many Items (raster and textItems) that should be moved even with drag'n'drop.

Im wondering what can be a good practice to accomplish this - my first thought was to get the bounds of every item into the middle group at every mouseDown, then considering the index order check manually which element to move (this mean to almost create a manual-hitTest), becose in the documentation i didnt find how to tell the hitTest to consider only items inside a specific group (without marking it as selected, i dont like to have the blue guidelines visibles).


So, what you guys think about?


p.s: apologies for my bad english

Jonathan Puckey

unread,
Nov 23, 2012, 11:04:53 AM11/23/12
to pap...@googlegroups.com
you can hitTest a specific group or item:

var hitResult = group.hitTest(point);

if (hitResult) {
hitResult.item.remove();

Strae

unread,
Nov 26, 2012, 10:34:50 AM11/26/12
to pap...@googlegroups.com
Thanks!
I did wonder something about that ;)
Reply all
Reply to author
Forward
0 new messages