]> git.neil.brown.name Git - edlib.git/commitdiff
autospell: cancel old menu before opening a new one.
authorNeilBrown <neil@brown.name>
Tue, 29 Aug 2023 01:39:16 +0000 (11:39 +1000)
committerNeilBrown <neil@brown.name>
Tue, 29 Aug 2023 01:39:16 +0000 (11:39 +1000)
If the previous spell-fix menu is still open when a new one is opened,
close the old one.

Signed-off-by: NeilBrown <neil@brown.name>
python/lib-autospell.py

index 33590d0f0d064369c13f4e4d13cac77b9387132a..6bb5287bec92e228bd6f2d888d9d8d738fff61cc 100644 (file)
@@ -202,6 +202,7 @@ class autospell_view(edlib.Pane):
         # visible region
         self.vstart = None
         self.vend = None
+        self.menu = None
         self.call("doc:request:spell:recheck")
         self.call("doc:request:doc:replaced")
         # trigger render-lines refresh notification
@@ -232,6 +233,8 @@ class autospell_view(edlib.Pane):
 
     def handle_click(self, key, focus, mark, xy, str1, **a):
         "handle:autospell-menu"
+        if self.menu:
+            self.menu.call("Cancel")
         mp = self.call("attach-menu", "", "autospell-choice", xy, ret='pane')
         self.wordend = mark.dup()
         st = mark.dup()
@@ -245,6 +248,13 @@ class autospell_view(edlib.Pane):
         self.add_notify(mp, "Notify:Close")
         return 1
 
+    def handle_notify_close(self, key, focus, **a):
+        "handle:Notify:Close"
+        if focus == self.menu:
+            self.menu = None
+            return 1
+        return edlib.Efallthrough
+
     def handle_choice(self, key, focus, mark, str1, **a):
         "handle:autospell-choice"
         if not str1: