(self, event)
| 1736 | # ── scene events ───────────────────────────────────────────────────────── |
| 1737 | |
| 1738 | def mousePressEvent(self, event): |
| 1739 | pos = snap(event.scenePos()) |
| 1740 | |
| 1741 | if self._mode == _Mode.PLACING and event.button() == Qt.LeftButton: |
| 1742 | self._push_undo() |
| 1743 | item = ComponentItem( |
| 1744 | self._placing_name, |
| 1745 | self._next_id(self._placing_name), |
| 1746 | self._placing_svg, |
| 1747 | ) |
| 1748 | item.setPos(pos) |
| 1749 | self.addItem(item) |
| 1750 | self._sync_junctions() |
| 1751 | self._remove_short_circuit_wires() |
| 1752 | self._sync_junctions() |
| 1753 | |
| 1754 | elif self._mode == _Mode.PLACING_JUNCTION and event.button() == Qt.LeftButton: |
| 1755 | self._push_undo() |
| 1756 | self.addItem(JunctionItem(pos)) |
| 1757 | self._sync_junctions() |
| 1758 | |
| 1759 | elif self._mode == _Mode.PLACING_TEXT and event.button() == Qt.LeftButton: |
| 1760 | self._push_undo() |
| 1761 | item = FreeTextItem(self._placing_text or "Text", pos) |
| 1762 | self.addItem(item) |
| 1763 | self._cancel_placement() |
| 1764 | |
| 1765 | elif self._mode == _Mode.PLACING_HYPERLINK and event.button() == Qt.LeftButton: |
| 1766 | self._push_undo() |
| 1767 | url, label = self._hyperlink_pending or ("", "") |
| 1768 | self.addItem(HyperlinkItem(url, label, pos)) |
| 1769 | self._cancel_placement() |
| 1770 | |
| 1771 | elif self._mode == _Mode.PLACING_COMMAND and event.button() == Qt.LeftButton: |
| 1772 | self._push_undo() |
| 1773 | item = CommandItem(".", pos) |
| 1774 | self.addItem(item) |
| 1775 | self._cancel_placement() |
| 1776 | item.setTextInteractionFlags(Qt.TextEditorInteraction) |
| 1777 | item.setFocus() |
| 1778 | c = item.textCursor() |
| 1779 | c.movePosition(QTextCursor.End) |
| 1780 | item.setTextCursor(c) |
| 1781 | |
| 1782 | elif self._mode == _Mode.PLACING_BORDER and event.button() == Qt.LeftButton: |
| 1783 | self._push_undo() |
| 1784 | for existing in [i for i in self.items() if isinstance(i, BorderItem)]: |
| 1785 | self.removeItem(existing) |
| 1786 | w, h, show = self._border_pending |
| 1787 | self.addItem(BorderItem(pos.x(), pos.y(), w, h, show)) |
| 1788 | self._cancel_placement() |
| 1789 | |
| 1790 | elif self._mode == _Mode.PLACING_LIBRARY and event.button() == Qt.LeftButton: |
| 1791 | self._push_undo() |
| 1792 | fp, directive, simulator, corner = self._library_pending |
| 1793 | self.addItem(LibraryItem(fp, pos, directive, simulator, corner)) |
| 1794 | self._cancel_placement() |
| 1795 |
nothing calls this directly
no test coverage detected