title: Prompt input on double click on cell in google sheet using google script
body: <p>I'd like to prompt an input box when I double click on a cell in Google Sheet.
  The perfect example is when you protect a range in Google Sheet, whoever tries to double click on the protected range gets a prompted message box. I want to do the same with a input box instead.</p>
  
  <p>The simplified version of the code I use is:</p>
  
  <pre><code>function editCell(e){
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("*** SEARCH ***");
    var lule = sheet.getActiveCell().getValue();
      SpreadsheetApp.flush();
  
    var ui = SpreadsheetApp.getUi();
    var response = ui.prompt('Edit Contact ', '('+lule+')', ui.ButtonSet.OK_CANCEL);
  
    // Process the user's response.
    if (response.getSelectedButton() == ui.Button.OK) {
      var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Contacts");
      ss.insertRow(1)
      ss.getRange(1,1).setValue(response.getResponseText());
    }
    else if (response.getSelectedButton() == ui.Button.CANCEL) {
      Logger.log('no');
    }
    else {
    Logger.log('nope');
    }
  }
  </code></pre>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>UPDATED CODE</p>
  
  <pre><code>function setCell(){
    //e.source.toast('flag1');
    var sh = SpreadsheetApp.getActiveSpreadsheet();
    if(sh.getSheetName() == "Contacts" == true){
      Logger.log('nope');
    }
    else if(sh.getSheetName() == "*** SEARCH ***" == true){
  
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("*** SEARCH ***")
      var cel = sheet.getActiveCell();    
      var val = cel.getValue();    
      var row = cel.getRow();
      var col = cel.getColumn();
      cel.setValue("");
      var lule = sheet.getRange(row,col).getValue();
      var line = sheet.getRange(row,1,1,1).getValue();
      sheet.getRange("A4").setValue(line)
      sheet.getRange("A5").setValue(col)
  
      var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Contacts");
          ss.getRange(line+4,col).setValue(val);
  
    }
  }
  </code></pre>