Skip to content

Conversation

@izhanlara
Copy link

Hi everyone,
#29
We have extracted the properties so that they are not repeated since they were repeated several times, in this way we have it centralized and it allows modifications in the future.
Image

We create the right click function:
Image

All code:
Image

Copy link
Collaborator

@pcolt pcolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, thanks! Just few comments and changes to check and make.
Also, @izhanlaraagarcia use prettier or npm run format to format your code.

function handleRightClick(event) {
const hitResult = paper.project.hitTest(event.point, drawingConfig.hitTest);

if (hitResult?.item.className === 'Path') {
Copy link
Collaborator

@pcolt pcolt Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check also if the path is not part of the grid or if we hit a point (those cases would rise an error).
The code below is working fine for me:

if (
    hitResult?.type === 'stroke' &&
    hitResult?.item.className === 'Path' &&
    hitResult.item.parent?.name !== 'grid'
  )

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pcolt,
This code it's working. You like to change and add your if?
`function handleRightClick(event) {
const hitResult = paper.project.hitTest(event.point, drawingConfig.hitTest);

if (hitResult?.item.className === 'Path') {
    selectedLine = hitResult.item;
    createContextMenu(event.event);
    return true; // The right-click found a target and was handled
}
return false;

}`

Image

`function handleRightClick(event) {
const hitResult = paper.project.hitTest(event.point, drawingConfig.hitTest);

if (
  hitResult?.type === 'stroke' &&
  hitResult?.item.className === 'Path' &&
  hitResult.item.parent?.name !== 'grid'
) {
    selectedLine = hitResult.item;
    createContextMenu(event.event);
    return true;
}
return false;

}`

Image

It's the same result. You say.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to right click on a red point or on the empty grid and then click Delete and you should see an error in the console tab
Screencast from 2025-10-08 09-05-36.webm

paper.view.onMouseDown = function (event) {
// Handle right-clicks (Guard Clause)
if (event.event.button === 2) {
if (handleRightClick(event)) {
Copy link
Collaborator

@pcolt pcolt Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you checking here if the function returns true or false? I would just call the handleRightClick() function here and let the function handle all the cases without any unneeded complexity. If the event is a right click I would always stop here, or I am missing something? (I currently do know better the 3D part of this application)

createContextMenu(event.event);
return true; // The right-click found a target and was handled
}
return false; // Nothing was done
Copy link
Collaborator

@pcolt pcolt Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the comment on line 261 and remove those returns if not needed

@izhanlara
Copy link
Author

@pcolt Changes on me local code:
Remove the comment on line: 255
Remove block code the lines 261 to 268.

Awaing to reply on me comment of:

if (
  hitResult?.type === 'stroke' &&
  hitResult?.item.className === 'Path' &&
  hitResult.item.parent?.name !== 'grid'
)

After this I push

@pcolt
Copy link
Collaborator

pcolt commented Oct 8, 2025

@izhanlaraagarcia please see my new comment #45 (comment)

@pcolt
Copy link
Collaborator

pcolt commented Oct 9, 2025

@izhanlaraagarcia also remove your changes to file package-lock.json

@izhanlara
Copy link
Author

@pcolt done

@pcolt
Copy link
Collaborator

pcolt commented Oct 13, 2025

Thank you, you fixed the package-lock.json but the other comments are still to be addressed

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

Successfully merging this pull request may close these issues.

2 participants