| 1 |
From: Piotr Wawrzyniak <[email protected]> |
| 2 |
Date: Wed, 16 Feb 2022 23:04:44 +0100 |
| 3 |
Subject: 1) checking whether focused object is an atom, |
| 4 |
not bond 2) allowing function for working for selected atom not only |
| 5 |
focused. |
| 6 |
|
| 7 |
--- |
| 8 |
bkchem/modes.py | 11 +++++++++-- |
| 9 |
1 file changed, 9 insertions(+), 2 deletions(-) |
| 10 |
|
| 11 |
diff --git a/bkchem/modes.py b/bkchem/modes.py |
| 12 |
index c1496c7..fdbf51c 100644 |
| 13 |
--- a/bkchem/modes.py |
| 14 |
+++ b/bkchem/modes.py |
| 15 |
@@ -737,9 +737,16 @@ class edit_mode(basic_mode): |
| 16 |
|
| 17 |
|
| 18 |
def add_chain( self, n): |
| 19 |
- if not self.focused: |
| 20 |
+ if not self.focused and len(Store.app.paper.selected) != 1: |
| 21 |
+ return |
| 22 |
+ if self.focused and not isinstance(self.focused, atom): |
| 23 |
+ return |
| 24 |
+ if Store.app.paper.selected and not isinstance(Store.app.paper.selected[0], atom): |
| 25 |
return |
| 26 |
- a = self.focused |
| 27 |
+ if self.focused: |
| 28 |
+ a = self.focused |
| 29 |
+ else: |
| 30 |
+ a = Store.app.paper.selected[0] |
| 31 |
mol = a.molecule |
| 32 |
for i in range( n): |
| 33 |
a, b = mol.add_atom_to( a) |