From: NeilBrown Date: Tue, 29 Aug 2023 01:39:16 +0000 (+1000) Subject: autospell: cancel old menu before opening a new one. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=91a7f58986555f1a470371efde4ba432c2fa54de;p=edlib.git autospell: cancel old menu before opening a new one. If the previous spell-fix menu is still open when a new one is opened, close the old one. Signed-off-by: NeilBrown --- diff --git a/python/lib-autospell.py b/python/lib-autospell.py index 33590d0f..6bb5287b 100644 --- a/python/lib-autospell.py +++ b/python/lib-autospell.py @@ -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: