MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / handleItemClick

Function handleItemClick

renderer.js:16439–16481  ·  view source on GitHub ↗
(itemValue)

Source from the content-addressed store, hash-verified

16437 // Regular menu item click
16438 menuItem.addEventListener('click', async (e) => {
16439 e.stopPropagation();
16440 try {
16441 await window.electron.executeContextMenuAction(menuData.requestId, index, null);
16442 menu.remove();
16443 } catch (error) {
16444 console.error('Error executing menu action:', error);
16445 alert('Error: ' + error.message);
16446 }
16447 });
16448 }
16449 }
16450
16451 menu.appendChild(menuItem);
16452 });
16453
16454 // Add to document
16455 document.body.appendChild(menu);
16456
16457 // Adjust position if menu goes off screen
16458 const rect = menu.getBoundingClientRect();
16459 if (rect.right > window.innerWidth) {
16460 menu.style.left = `${x - rect.width}px`;
16461 }
16462 if (rect.bottom > window.innerHeight) {
16463 menu.style.top = `${y - rect.height}px`;
16464 }
16465
16466 // Close menu when clicking outside
16467 const closeMenu = (e) => {
16468 if (!menu.contains(e.target)) {
16469 menu.remove();
16470 document.removeEventListener('click', closeMenu);
16471 document.removeEventListener('contextmenu', closeMenu);
16472 }
16473 };
16474
16475 // Close on escape key
16476 const handleEscape = (e) => {
16477 if (e.key === 'Escape') {
16478 menu.remove();
16479 document.removeEventListener('keydown', handleEscape);
16480 document.removeEventListener('click', closeMenu);
16481 document.removeEventListener('contextmenu', closeMenu);
16482 }
16483 };
16484

Callers 1

renderListItemsFunction · 0.85

Calls 4

addTagToModelFunction · 0.85
getCurrentModelFilePathFunction · 0.85
autoSaveMultipleModelsFunction · 0.85
autoSaveModelFunction · 0.85

Tested by

no test coverage detected