0181c924ddf9e4c601fdd0f0bd3180e265ee50c3
max
  Mon Jun 8 07:36:42 2020 -0700
small js fix to allow copy/paste from position box on hgTracks, refs #25678

diff --git src/hg/js/autocomplete.js src/hg/js/autocomplete.js
index 5a7ea93..d7734cb 100644
--- src/hg/js/autocomplete.js
+++ src/hg/js/autocomplete.js
@@ -42,30 +42,32 @@
     },
 
     clearFindMatches: function() {
         // clear any hgFind.matches set by a previous user selection (e.g. when user directly edits the search box)
         if ($('#hgFindMatches').length) $('#hgFindMatches').remove();
     },
 
     updateFindMatches: function(val) {
         // highlight genes choosen from suggest list (#6330)
         if ($('#hgFindMatches').length) $('#hgFindMatches').val(val);
         else $('#positionInput').parents('form').append("<input type='hidden' id='hgFindMatches' name='hgFind.matches' " + "value='" + val + "'>");
     },
 
     initialized: false,
 
+    lastMouseDown : null,
+
     init: function(db, assemblySupportsGeneSuggest, selectCallback, clickCallback) {
         // selectCallback(item): called when the user selects a new genomic position from the list
         // clickCallback(position): called when the user clicks on positionDisplay
         this.initialized = true;
         var lastSelected = null; // this is the last value entered by the user via a suggestion (used to distinguish manual entry in the same field)
         var $posInput = $('#positionInput');
         var waterMark;
         if (assemblySupportsGeneSuggest) {
             if (db.match(/^hg[0-9]+/)) {
                 // Mention HGVS variant notation for human assemblies only, although it should work
                 // with any assembly that has refGene or ncbiRefSeq.
                 waterMark = "enter position, gene symbol, HGVS or search terms";
             } else {
                 waterMark = "enter position, gene symbol or search terms";
             }
@@ -116,27 +118,35 @@
         // $('#positionInput').focus();
         $("#positionInput").change(function(event) {
             if (!lastSelected || lastSelected !== $('#positionInput').val()) {
                 // This handles case where user typed or edited something rather than choosing from a suggest list;
                 // in this case, we only change the position hidden; we do NOT update the displayed coordinates.
                 var val = $('#positionInput').val();
                 // handles case where users zeroes out positionInput; in that case we revert to currently displayed position
                 if (!val || val.length === 0 || val === waterMark)
                     val = $('#positionDisplay').text();
                 else
                     val = val.replace(/\u2013|\u2014/g, "-");  // replace en-dash and em-dash with hyphen
                 $('#position').val(val);
                 suggestBox.clearFindMatches();
             }
         });
-        $("#positionDisplay").click(function(event) {
+
+        $("#positionDisplay").mousedown(function(event) {
+            // this let's the user click on the genomic position (e.g. if they want to edit it)
+            lastMouseDown = event.offsetX;
+        });
+
+        $("#positionDisplay").mouseup(function(event) {
+            if (event.offsetX !== lastMouseDown)
+                return; 
             // this let's the user click on the genomic position (e.g. if they want to edit it)
             clickCallback($(this).text());
             $('#positionInput').val($(this).text());
             suggestBox.clearFindMatches();
             if (hgTracks.windows)
                 {
                 genomePos.positionDisplayDialog();
                 }
         });
     }
 };