首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何调整用户提示符的大小,以便出现一个框而不是一行?

如何调整用户提示符的大小,以便出现一个框而不是一行?
EN

Stack Overflow用户
提问于 2019-02-15 16:20:41
回答 1查看 783关注 0票数 1

我正在使用ui.prompt()来为我的应用程序脚本的其余部分提供用户输入。但是,如果用户输入响应的空间更大,那么如果他们必须输入相当多的内容(4-5句话),则整个文本是可见的,而不是鼠标移动到输入的开头/结尾。

我不确定是否有一个函数允许我为输入部分设置一个自定义大小(高度和宽度,或者变量,比如文本窗口的“拖动角”)。

代码语言:javascript
复制
  var ui = SpreadsheetApp.getUi();

  var bodyresponse = ui.prompt(

  "The default email template is: " + 

  "\n\nIf you have any questions regarding your order, please email us directly by replying." +
  "\n\nIf you would like to update your contact information, billing/shipping address, " + 
  "or have an adjustment to make on the Purchase Order attached to this email, " +
  "please reach out to us within 7 days of receiving this Purchase Order." + 
  "\n\nThank you from Area Code 407!" +

  "\n\nWould you like to include an accompanying note? If so, include it below: \n\n\n\n ", 

  ui.ButtonSet.YES_NO);

在这里输入图像描述

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-15 17:54:21

不幸的是,提示功能将不允许您这样做。但是,您可以通过制作一个对话框来实现您想要的结果。然后,使用客户端到服务器的通信,您可以将信息传递回服务器端脚本。

这不是一个完美的例子,而是需要做什么的一般想法。

Code.gs

代码语言:javascript
复制
var htmlOutput = HtmlService
    .createHtmlFromFile('Dialog')
    .setWidth(250)
    .setHeight(300);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'My Title');

function dialogData(userNote){
   //Do something with userNote...
}

Dialog.html

代码语言:javascript
复制
<body>
  Hello, world!
  <p> The default email template is: </p>

  <p>If you have any questions regarding your order, please email us directly by replying. If you would like to update your contact information, billing/shipping address, or have an adjustment to make on the Purchase Order attached to this email, please
    reach out to us within 7 days of receiving this Purchase Order.</p>
  <p>Thank you from Area Code 407! </p>

  <p>Would you like to include an accompanying note? If so, include it below: </p>
  <textarea id="userNote" rows="4" cols="80"></textarea>
  <input type="button" value="Submit" onclick="returnData()" />
  <script>
    function returnData() {
      var note = document.getElementById("userNote").value
      console.log(note);
      google.script.run.onSuccessHandler(closeMe).dialogData(); //This calls a script in your main Code.gs serverside.
    }

    function closeMe() {
      google.script.host.close();
    }
  </script>
</body>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54713254

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档