From: NeilBrown Date: Thu, 19 Oct 2023 09:31:01 +0000 (+1100) Subject: url: slow click doesn't activate link X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=7bfd5c655a02675fb1124ef70062d5371c20299c;p=edlib.git url: slow click doesn't activate link A slow click will display the link only. A fast click is needed, or a repeated Enter, to activate it. Signed-off-by: NeilBrown --- diff --git a/python/lib-url.py b/python/lib-url.py index e0176dbc..310e9a9b 100644 --- a/python/lib-url.py +++ b/python/lib-url.py @@ -12,6 +12,7 @@ # - handles Acivate:url to also activate the url import edlib +import time def mark_urls(key, focus, mark, mark2, **a): doc = focus @@ -56,6 +57,7 @@ class url_view(edlib.Pane): def __init__(self, focus): edlib.Pane.__init__(self, focus) self.displayed_tag = None + self.down_time = 0 def handle_map_attr(self, key, focus, mark, str1, str2, comm2, **a): "handle:map-attr" @@ -92,8 +94,13 @@ class url_view(edlib.Pane): url = focus["url:" + tag] if url: focus.call("Message", "Url: <%s>" % url) - if self.displayed_tag == tag and str2 != "prepare": + if str2 == "prepare": + self.down_time = time.time() + if (self.displayed_tag == tag and str2 != "prepare" and + (self.down_time == 0 or self.down_time + 1 > time.time())): focus.call("Window:external-viewer", url) + if str2 != "prepare": + self.down_time = 0 self.displayed_tag = tag else: focus.call("Message", "URL tag %s not found" % tag)