Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hitTestAll method doesn't return Group path #2069

Open
KmXK opened this issue Mar 9, 2024 · 0 comments
Open

hitTestAll method doesn't return Group path #2069

KmXK opened this issue Mar 9, 2024 · 0 comments

Comments

@KmXK
Copy link

KmXK commented Mar 9, 2024

Description/Steps to reproduce

hitTestAll method for Project object does not return Group object but his children when color of one of the object differs.

Example:

// paperscript
settings.insertItems = false
const rect1 = new Path.Rectangle([0], [100, 100])
rect1.fillColor = 'red'
rect1.strokeColor = 'black'

const rect2 = new Path.Rectangle([25, 25], [50, 50])
rect2.fillColor = 'red'
rect2.strokeColor = 'black'

const group = new Group(rect1, rect2)

project.activeLayer.addChild(group)

console.log(project.hitTestAll([30, 30]))

Here hitTestAll method will return array with 3 elements: 2 Rectangle paths and one Group.

Next example:

settings.insertItems = false
const rect1 = new Path.Rectangle([0], [100, 100])
rect1.fillColor = 'red'
rect1.strokeColor = 'black'

const rect2= new Path.Rectangle([25, 25], [50, 50])
rect2.fillColor = 'white'
rect2.strokeColor = 'black'

const group = new Group(rect1, rect2)

project.activeLayer.addChild(group)

console.log(project.hitTestAll([30, 30]))

This code will return only group's children and will skip Group object.

Maybe this link to Sketch will be useful.

Expected result

hitTestAll returns both Group and it's elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant