]> git.neil.brown.name Git - edlib.git/commitdiff
url: slow click doesn't activate link
authorNeilBrown <neil@brown.name>
Thu, 19 Oct 2023 09:31:01 +0000 (20:31 +1100)
committerNeilBrown <neil@brown.name>
Thu, 19 Oct 2023 09:34:15 +0000 (20:34 +1100)
A slow click will display the link only.  A fast click is needed,
or a repeated Enter, to activate it.

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

index e0176dbce98f83da2edc4037d8f43f081a0c04ec..310e9a9b9c3156a963746b9a88d6fb37ab10a719 100644 (file)
@@ -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)