panel - Automatically close a Google Apps Script UiApp after five seconds -


i want automatically close uiapp after number of seconds:

function showconfirmationdialogue() {   var app = uiapp.createapplication().setheight('80').setwidth('400');   app.settitle('test');   var panel = app.createverticalpanel();   app.add(panel);    var doc = spreadsheetapp.getactive();   doc.show(app);    // part doesn't seem work   utilities.sleep(5000);   app.close();   return app; } 

thanks!

the ui create shown when call doc.show(app) , way can update or close use handler function ends return app.

so not possible want same function creates ui since "returned" 1 time.

i know 1 trick can achieve want using handler trigger source call closing handler function automatically using "special" property of checkbox widget. here code, uses checkbox can of course make invisible in final code.

function showconfirmationdialogue() {   var app = uiapp.createapplication().setheight('80').setwidth('400');   app.settitle('test');   var panel = app.createverticalpanel();   app.add(panel);   var handler = app.createserverhandler('closewindow');   var chk = app.createcheckbox('checkbox set invisible in real function').setvalue(false,true).addvaluechangehandler(handler);   app.add(chk);   chk.setvalue(true,true)//.setvisible(false);   var doc = spreadsheetapp.getactive();   doc.show(app); }  function closewindow(){   utilities.sleep(5000);   var app = uiapp.getactiveapplication().close();   return app; } 

you can use same procedure modify uiapp instance in way, change label text, add widget... want.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -