Google アプリ スクリプトを使用するのはこれが初めてで、複数の機能からウィジェットにアクセスする方法について少し混乱しています。
基本的に、label
ウィジェットを更新するボタンが欲しいです。したがって、ラベルにはデフォルトのテキストがありますが、「更新」ボタンが押されると、更新されて他のテキストが表示されます。
私が読んだところによると、イベント ハンドラーに渡すことができるのは、setName
メソッドを持つオブジェクトだけです。ウィジェットにはこれがないので、関数内のウィジェットの値を他のハンドラー関数からlabel
更新するにはどうすればよいですか?doGet
これが私がやりたいことのアイデアです(しかし、仕事に取り掛かることはできません):
function doGet() {
var app = UiApp.createApplication();
// Create the label
var myLabel = app.createLabel('this is my label')
app.add(myLabel)
// Create the update button
var updateButton = app.createButton('Update Label');
app.add(updateButton)
// Assign the update button handler
var updateButtonHandler = app.createServerHandler('updateValues');
updateButton.addClickHandler(updateButtonHandler);
return app;
}
function updateValues() {
var app = UiApp.getActiveApplication();
// Update the label
app.myLabel.setLabel('This is my updated label')
return app;
}
私は解決策を見つけようとして何時間もインターネットを探し回っていますが、それを理解できないようです. 助言がありますか?