Google Apps 脚本中的简单弹出窗口或对话框 [英] Simple popup or dialog box in Google Apps Script

查看:26
本文介绍了Google Apps 脚本中的简单弹出窗口或对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在我的 Google Apps 脚本 Ui 中添加一个弹出窗口的简单代码,当我点击提交按钮时会出现该弹出窗口.弹出框会显示一条消息,并有一个关闭弹出框的按钮.

I'm looking for simple code that adds a popup in my Google Apps Script Ui that comes up when I hit a submit button. The popup box would display a message and have a button to close the popup.

我已经到处查看了 - 一切似乎都很复杂,而且做得比我需要做的要多.

I've looked all over the place - everything seems so complicated and does way more than I need it to do.

这是提交按钮的当前代码.

This is the current code I have for the submit button.

     function doGet() {
       var app = UiApp.createApplication();
       app.setTitle("My Logbook");

       var hPanel_01 = app.createHorizontalPanel();
       var vPanel_01 = app.createVerticalPanel();
       var vPanel_02 = app.createVerticalPanel();
       var vPanel_03 = app.createVerticalPanel();

       var submitButton = app.createButton("Submit");

       //Create click handler
       var clickHandler = app.createServerHandler("submitData");
       submitButton.addClickHandler(clickHandler);
       clickHandler.addCallbackElement(hPanel_01);


       ////Test PopUp Panel
       var app = UiApp.getActiveApplication();
       var app = UiApp.createApplication;
       var dialog = app.createDialogBox();
       var closeHandler = app.createClientHandler().forTargets(dialog).setVisible(false);
       submitButton.addClickHandler(closeHandler);

       var button= app.createButton('Close').addClickHandler(closeHandler);

       dialog.add(button);
       app.add(dialog);
       //////



       return app;
     }

推荐答案

你试过使用zIndex吗?它将面板置于所有其他面板之上...

Have you tried using zIndex? It places the panel above all of your other panels...

var popupPanel = app.createVerticalPanel().setId('popupPanel')
    .setVisible(false)      
    .setStyleAttribute('left', x)  
    .setStyleAttribute('top', y)        
    .setStyleAttribute('zIndex', '1')
    .setStyleAttribute('position', 'fixed');

x = 应用左侧的面板位置y = 应用顶部的面板位置zIndex = 您的面板将出现的层".您可以使用1"、2"、3"等来堆叠面板.position = 您的面板将处于由 (x,y) 表示的固定位置

x = panel position from the left portion of your app y = panel position from the top portion of your app zIndex = the 'layer' your panel will appear on. You can stack panels using '1', '2', '3' etc. position = your panel will be in a fixed position denoted by (x,y)

Visibility 设置为 false,直到您单击提交,然后让您的提交按钮的客户端处理程序使 popupPanel 可见.当您单击 popupPanel 上的按钮时,让客户端处理程序再次将可见性设置为 false,它将消失.

Visibility is set to false until you click submit, then have a client handler for your submit button make the popupPanel visible. When you click the button on your popupPanel, have the client handler set visibility to false once again and it will disappear.

还有一件事,我注意到您获得了活动应用,然后创建了一个新应用.您无需创建新应用...只需在应用内创建新面板即可.

One more thing, I noticed you get the active app and then create a new app. You do not need to create a new app...just new panels inside your app.

希望这会有所帮助!

这篇关于Google Apps 脚本中的简单弹出窗口或对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆