A representation of a user interface.
You can use this to create a new user interface or manipulate an existing one.
Methods
Detailed documentation
add(child)
Adds a new widget to this application.
The new widget will be a part of the children widgets of this application. The new widget is added to the end of the list of widgets currently in the application.
Parameters
Name | Type | Description |
---|---|---|
child | Widget | the new widget to add to the application. |
Return
UiInstance
— the application itself, useful for chaining.
close()
Close the app.
This will only work if the app is being shown as a dialog, such as in a Google Spreadsheet. It will have no effect when called on an app that is published as a standalone service.
Return
UiInstance
— the application itself, useful for chaining.
createAnchor(text, asHtml, href)
Creates a new Anchor
.
This is essentially a hyperlink and represents an <a>
element.
This widget is based on GWT's anchor class.
Parameters
Name | Type | Description |
---|---|---|
text | String | the text to display to the user as the anchor's text. |
asHtml | Boolean | whether to render that text as HTML. |
href | String | the address to go to when the anchor is clicked. |
Return
Anchor
— the new Anchor.
createAnchor(text, href)
Creates a new Anchor
.
This is essentially a hyperlink and represents an <a>
element.
This widget is based on GWT's anchor class.
Parameters
Name | Type | Description |
---|---|---|
text | String | the text to display to the user as the anchor's text. |
href | String | the address to go to when the anchor is clicked. |
Return
Anchor
— the new Anchor.
createButton(html)
Creates a new Button
.
Parameters
Name | Type | Description |
---|---|---|
html | String | the new Button's text, rendered as HTML. |
Return
Button
— the new Button.
createButton(html, clickHandler)
Creates a new Button
.
Parameters
Name | Type | Description |
---|---|---|
html | String | the new Button's text, rendered as HTML. |
clickHandler | Handler | a click handler for the new button. This can be a ClientHandler or
a ServerHandler . |
Return
Button
— the new Button.
createCaptionPanel(caption)
Creates a new CaptionPanel
.
Parameters
Name | Type | Description |
---|---|---|
caption | String | the CaptionPanel's caption text, not rendered as HTML. |
Return
CaptionPanel
— the new CaptionPanel.
createCaptionPanel(caption, asHtml)
Creates a new CaptionPanel
.
Parameters
Name | Type | Description |
---|---|---|
caption | String | the CaptionPanel's caption text. |
asHtml | Boolean | whether to render the caption text as HTML. |
Return
CaptionPanel
— the new CaptionPanel.
createCheckBox(label)
Creates a new CheckBox
.
Parameters
Name | Type | Description |
---|---|---|
label | String | the CheckBox's label text, not rendered as HTML. |
Return
CheckBox
— the new CheckBox.
createCheckBox(label, asHtml)
Creates a new CheckBox
.
Parameters
Name | Type | Description |
---|---|---|
label | String | the CheckBox's label text. |
asHtml | Boolean | whether to render the label text as HTML. |
Return
CheckBox
— the new CheckBox.
createClientHandler()
Creates a new ClientHandler
.
A ClientHandler can be used anywhere a ServerHandler can be. See the documentation of
ClientHandler
and the User Guide to understand how to specify what a ClientHandler will
do in response to an event.
Return
ClientHandler
— the new ClientHandler.
createDecoratedStackPanel()
Creates a new DecoratedStackPanel
.
Return
DecoratedStackPanel
— the new DecoratedStackPanel.
createDecoratedTabBar()
Creates a new DecoratedTabBar
.
Return
DecoratedTabBar
— the new DecoratedTabBar.
createDecoratedTabPanel()
Creates a new DecoratedTabPanel
.
Return
DecoratedTabPanel
— the new DecoratedTabPanel.
createDecoratorPanel()
Creates a new DecoratorPanel
.
Return
DecoratorPanel
— the new DecoratorPanel.
createDialogBox()
Creates a new DialogBox
.
The dialog will not auto-hide and is not modal.
Return
DialogBox
— the new DialogBox.
createDialogBox(autoHide)
Creates a new DialogBox
.
The dialog is not modal.
Parameters
Name | Type | Description |
---|---|---|
autoHide | Boolean | whether the dialog should auto-hide when the user clicks outside of it. |
Return
DialogBox
— the new DialogBox.
createDialogBox(autoHide, modal)
Creates a new DialogBox
.
Parameters
Name | Type | Description |
---|---|---|
autoHide | Boolean | whether the dialog should auto-hide when the user clicks outside of it. |
modal | Boolean | whether the dialog is modal, meaning that keyboard or mouse events that do not target the DialogBox or its children will be ignored. |
Return
DialogBox
— the new DialogBox.
createFocusPanel(child)
Creates a new FocusPanel
with a specified child Widget
.
Parameters
Name | Type | Description |
---|---|---|
child | Widget | the child widget. |
Return
FocusPanel
— the new FocusPanel.
createGrid()
Creates a new Grid
.
Until the Grid is explicitly resized, no widgets can't be added to it.
Return
Grid
— the new Grid.
createGrid(rows, columns)
Creates a new Grid
with a specified size.
Parameters
Name | Type | Description |
---|---|---|
rows | Integer | the number of rows |
columns | Integer | the number of columns |
Return
Grid
— the new Grid.
createHTML(html)
Creates a new HTML
with the specified text.
Parameters
Name | Type | Description |
---|---|---|
html | String | the HTML's text, rendered as HTML. |
Return
HTML
— the new HTML.
createHTML(html, wordWrap)
Creates a new HTML
with the specified text.
Parameters
Name | Type | Description |
---|---|---|
html | String | the HTML's text, rendered as HTML. |
wordWrap | Boolean | whether to allow the text to wrap. |
Return
HTML
— the new HTML.
createHidden(name)
Creates a new Hidden
with a specified name.
Parameters
Name | Type | Description |
---|---|---|
name | String | the hidden field's name. |
Return
Hidden
— the new Hidden.
createHidden(name, value)
Creates a new Hidden
with a specified name and value.
Parameters
Name | Type | Description |
---|---|---|
name | String | the hidden field's name. |
value | String | the hidden field's value. |
Return
Hidden
— the new Hidden.
createHorizontalPanel()
Creates a new HorizontalPanel
.
Return
HorizontalPanel
— the new HorizontalPanel.
createImage(url)
Creates a new Image
with the specified URL.
Parameters
Name | Type | Description |
---|---|---|
url | String | the URL of the image. |
Return
Image
— the new Image.
createImage(url, left, top, width, height)
Creates a new Image
with the specified URL and clipping rectangle.
Parameters
Name | Type | Description |
---|---|---|
url | String | the URL of the image. |
left | Integer | the left of the clipping rectangle, in pixels. |
top | Integer | the top of the clipping rectangle, in pixels. |
width | Integer | the width of the clipping rectangle, in pixels. |
height | Integer | the height of the clipping rectangle, in pixels. |
Return
Image
— the new Image.
createInlineLabel()
Creates a new InlineLabel
with no text.
Return
InlineLabel
— the new InlineLabel.
createInlineLabel(text)
Creates a new InlineLabel
with the specified text.
Parameters
Name | Type | Description |
---|---|---|
text | String | the label's text, not rendered as HTML. |
Return
InlineLabel
— the new InlineLabel.
createLabel(text)
Creates a new Label
with the specified text.
Parameters
Name | Type | Description |
---|---|---|
text | String | the label's text, not rendered as HTML. |
Return
Label
— the new Label.
createLabel(text, wordWrap)
Creates a new Label
with the specified text.
Parameters
Name | Type | Description |
---|---|---|
text | String | the label's text, not rendered as HTML. |
wordWrap | Boolean | whether to allow the text to wrap. |
Return
Label
— the new Label.
createListBox()
Creates a new ListBox
.
The ListBox will not allow multiple selections.
Return
ListBox
— the new ListBox.
createListBox(isMultipleSelect)
Creates a new ListBox
.
Parameters
Name | Type | Description |
---|---|---|
isMultipleSelect | Boolean | whether the ListBox should allow multiple selections. |
Return
ListBox
— the new ListBox.
createMenuBar()
Creates a new MenuBar
.
The MenuBar will display itself horizontally.
Return
MenuBar
— the new MenuBar.
createMenuBar(vertical)
Creates a new MenuBar
.
Parameters
Name | Type | Description |
---|---|---|
vertical | Boolean | whether the MenuBar should display itself vertically. |
Return
MenuBar
— the new MenuBar.
createMenuItem(text, asHtml, command)
Creates a new MenuItem
.
Parameters
Name | Type | Description |
---|---|---|
text | String | the text to display for this item. |
asHtml | Boolean | whether to render that text as HTML. |
command | Handler | the ClientHandler or ServerHandler to invoke when this item is
selected. |
Return
MenuItem
— the new MenuItem.
createMenuItem(text, command)
Creates a new MenuItem
.
Parameters
Name | Type | Description |
---|---|---|
text | String | the text to display for this item. |
command | Handler | the ClientHandler or ServerHandler to invoke when this item is
selected. |
Return
MenuItem
— the new MenuItem.
createMenuItemSeparator()
Creates a new MenuItemSeparator
.
Return
MenuItemSeparator
— the new MenuItemSeparator.
createPasswordTextBox()
Creates a new PasswordTextBox
.
Return
PasswordTextBox
— the new PasswordTextBox.
createPopupPanel()
Creates a new PopupPanel
.
The panel will not auto-hide and is not modal.
Return
PopupPanel
— the new PopupPanel.
createPopupPanel(autoHide)
Creates a new PopupPanel
.
The panel is not modal.
Parameters
Name | Type | Description |
---|---|---|
autoHide | Boolean | whether the panel should auto-hide when the user clicks outside of it. |
Return
PopupPanel
— the new PopupPanel.
createPopupPanel(autoHide, modal)
Creates a new PopupPanel
.
Parameters
Name | Type | Description |
---|---|---|
autoHide | Boolean | whether the panel should auto-hide when the user clicks outside of it. |
modal | Boolean | whether the panel is modal, meaning that keyboard or mouse events that do not target the PopupPanel or its children will be ignored. |
Return
PopupPanel
— the new PopupPanel.
createPushButton(upText)
Creates a new PushButton
.
Parameters
Name | Type | Description |
---|---|---|
upText | String | the up text |
Return
PushButton
— the new PushButton.
createPushButton(upText, clickHandler)
Creates a new PushButton
.
Parameters
Name | Type | Description |
---|---|---|
upText | String | the up text |
clickHandler | Handler | a click handler for the new button. This can be a ClientHandler or
a ServerHandler . |
Return
PushButton
— the new PushButton.
createPushButton(upText, downText)
Creates a new PushButton
.
Parameters
Name | Type | Description |
---|---|---|
upText | String | the up text |
downText | String | the down text. |
Return
PushButton
— the new PushButton.
createPushButton(upText, downText, clickHandler)
Creates a new PushButton
.
Parameters
Name | Type | Description |
---|---|---|
upText | String | the up text |
downText | String | the down text. |
clickHandler | Handler | a click handler for the new button. This can be a ClientHandler or
a ServerHandler . |
Return
PushButton
— the new PushButton.
createRadioButton(name)
Creates a new RadioButton
.
Parameters
Name | Type | Description |
---|---|---|
name | String | the RadioButton's name. Names are used for grouping RadioButtons; see the
documentation of RadioButton for more details. |
Return
RadioButton
— the new RadioButton.
createRadioButton(name, label)
Creates a new RadioButton
.
Parameters
Name | Type | Description |
---|---|---|
name | String | the RadioButton's name. Names are used for grouping RadioButtons; see the
documentation of RadioButton for more details. |
label | String | the RadioButton's label text, not rendered as HTML. |
Return
RadioButton
— the new RadioButton.
createRadioButton(name, label, asHtml)
Creates a new RadioButton
.
Parameters
Name | Type | Description |
---|---|---|
name | String | the RadioButton's name. Names are used for grouping RadioButtons; see the
documentation of RadioButton for more details. |
label | String | the RadioButton's label text. |
asHtml | Boolean | whether to render that text as HTML. |
Return
RadioButton
— the new RadioButton.
createResetButton(html)
Creates a new ResetButton
.
Parameters
Name | Type | Description |
---|---|---|
html | String | the text to show on the button, rendered as HTML. |
Return
ResetButton
— the new ResetButton.
createResetButton(html, clickHandler)
Creates a new ResetButton
.
Parameters
Name | Type | Description |
---|---|---|
html | String | the text to show on the button, rendered as HTML. |
clickHandler | Handler | a click handler for the new button. This can be a ClientHandler or
a ServerHandler . |
Return
ResetButton
— the new ResetButton.
createScrollPanel(child)
Creates a new ScrollPanel
with a specified child Widget
.
Parameters
Name | Type | Description |
---|---|---|
child | Widget | the child widget. |
Return
ScrollPanel
— the new ScrollPanel.
createServerHandler()
Creates a new ServerHandler
.
Server handlers are used by scripts to launch script functions in response to events in the
application. For example, a server handler can be added to a Button
with the
addClickHandler
method so that the handler will be invoked when the button is clicked.
Return
ServerHandler
— a new ServerHandler object.
createServerHandler(functionName)
Creates a new ServerHandler
.
Server handlers are used by scripts to launch script functions in response to events in the
application. For example, a server handler can be added to a Button
with the
addClickHandler
method so that the handler will be invoked when the button is clicked.
Parameters
Name | Type | Description |
---|---|---|
functionName | String | a script function that will be executed when this handler is invoked. |
Return
ServerHandler
— a new ServerHandler object.
createSimpleCheckBox()
Creates a new SimpleCheckBox
.
Return
SimpleCheckBox
— the new SimpleCheckBox.
createSimpleRadioButton(name)
Creates a new SimpleRadioButton
.
Parameters
Name | Type | Description |
---|---|---|
name | String | the SimpleRadioButton's name. Names are used for grouping RadioButtons; see the
documentation of SimpleRadioButton for more details. |
Return
SimpleRadioButton
— the new SimpleRadioButton.
createSplitLayoutPanel()
Creates a new SplitLayoutPanel
.
Return
SplitLayoutPanel
— the new SplitLayoutPanel.
createSubmitButton(html)
Creates a new SubmitButton
.
Parameters
Name | Type | Description |
---|---|---|
html | String | the text to show on the button, rendered as HTML. |
Return
SubmitButton
— the new SubmitButton.
createToggleButton(upText)
Creates a new ToggleButton
.
Parameters
Name | Type | Description |
---|---|---|
upText | String | the up text |
Return
ToggleButton
— the new ToggleButton.
createToggleButton(upText, clickHandler)
Creates a new ToggleButton
.
Parameters
Name | Type | Description |
---|---|---|
upText | String | the up text |
clickHandler | Handler | a click handler for the new button. This can be a ClientHandler or
a ServerHandler . |
Return
ToggleButton
— the new ToggleButton.
createToggleButton(upText, downText)
Creates a new ToggleButton
.
Parameters
Name | Type | Description |
---|---|---|
upText | String | the up text |
downText | String | the down text. |
Return
ToggleButton
— the new ToggleButton.
createTreeItem(text)
Creates a new TreeItem
with the given text.
Parameters
Name | Type | Description |
---|---|---|
text | String | the tree item's text, not rendered as HTML. |
Return
TreeItem
— the new TreeItem.
createTreeItem(child)
Creates a new TreeItem
with the given widget.
Parameters
Name | Type | Description |
---|---|---|
child | Widget | the widget to display on the item. |
Return
TreeItem
— the new TreeItem.
getElementById(id)
Retrieves a generic reference to an element stored in the application, by its id.
The reference is not 'aware' of whether any such widget actually exists. If there is no widget with the given id, or if there is such a widget but the method you call on it does not exist for that widget type, this will cause an error on the client when the UiInstance is returned.
This can be used to get existing widgets in the application when writing event handling
code. To set a widget's id, use the method setId
of the target widget. For Example:
function doGet() {
var app = UiApp.createApplication();
// create a label and set its id to 'labelId'
var label = app.createLabel("Hello").setId('labelId');
var button = app.createButton("OK", app.createServerHandler('onClick'));
app.add(label).add(button);
return app;
}
function onClick(event) {
var app = UiApp.getActiveApplication();
// retrieve the label from the application by id
var label = app.getElementById('labelId');
label.setText("World!");
return app;
}
Parameters
Name | Type | Description |
---|---|---|
id | String | the id of the requested widget. |
Return
Component
— a reference to a widget with that id
getId()
Returns the id that has been assigned to this object.
This can be used in conjunction with app.getElementById() to retrieve a reference to this object.
Return
String
— the id that has been assigned to this object
isStandardsMode()
Gets whether the UiApp displays in HTML 'standards' mode or in 'quirks' mode.
Return
Boolean
— whether the UiApp displays in HTML 'standards' mode or in 'quirks' mode
loadComponent(componentName)
Load a GUI Builder component into UiApp, by name.
Parameters
Name | Type | Description |
---|---|---|
componentName | String | the name of the component to load |
Return
Component
— the component, which can be added to an app
loadComponent(componentName, optAdvancedArgs)
Load a GUI Builder component into UiApp, by name.
Parameters
Name | Type | Description |
---|---|---|
componentName | String | the name of the component to load |
optAdvancedArgs | Object | an object with advanced settings such as 'prefix', which gets added to the id of any widget inside the component, and 'z-index', which specifies a base z-index that gets added to the z-index of any widgets inside the component. |
Return
Component
— the component, which can be added to an app
remove(index)
Remove the widget with the given index from the application. Indexes begin from 0. This will fail if the index is greater than or equal to the number of elements in the application.
Parameters
Name | Type | Description |
---|---|---|
index | Integer | the index of the widget to remove. |
Return
UiInstance
— the application itself, useful for chaining.
remove(widget)
Remove the given widget from the application. This will fail if the widget is not actually a child of the application.
Parameters
Name | Type | Description |
---|---|---|
widget | Widget | the widget to remove. |
Return
UiInstance
— the application itself, useful for chaining.
setHeight(height)
Sets the application's height.
This affects the height of the application when run as a service or the height of a dialog when an application is shown inside a spreadsheet.
Parameters
Name | Type | Description |
---|---|---|
height | Integer | the new height value in pixels. |
Return
UiInstance
— the application itself, useful for chaining.
setStandardsMode(standardsMode)
Set whether the UiApp displays in HTML 'standards' mode or in 'quirks' mode.
By default UiApp uses 'quirks' mode unless you use a GUI Builder component with loadComponent, in which case it defaults to 'standards'.
Parameters
Name | Type | Description |
---|---|---|
standardsMode | Boolean | whether to use standards mode |
Return
UiInstance
— this UiInstance, useful for chaining
setStyleAttribute(attribute, value)
Sets one of the application's style attributes to a new value.
Possible attributes are the same as those available in CSS style sheets. Since some CSS code may be malicious, attributes are whitelisted explicitly and therefore some CSS attributes may not be available.
The following example shows an application which background and text color is changed:
function doGet() {
var app = UiApp.createApplication();
// Change the app's background to black and
// text color to green
app.setStyleAttribute("background", "black")
.setStyleAttribute("color", "green");
// create a label
var label = app.createLabel("Hello World!");
app.add(label)
return app;
}
Parameters
Name | Type | Description |
---|---|---|
attribute | String | the CSS attribute, in camelCase. ("fontSize", not "font-size"). |
value | String | the CSS value |
Return
UiInstance
— the application itself, useful for chaining.
setTitle(title)
Sets the title of the application.
If this application will be run as a service, this will be used as the title of the page. If this application will be run as a dialog (for example inside a spreadsheet) it will be the title of the dialog's window.
Parameters
Name | Type | Description |
---|---|---|
title | String | the string to be used as the application's title. |
Return
UiInstance
— the application itself, useful for chaining.
setWidth(width)
Sets the application's width.
This affects the width of the application when run as a service or the width of a dialog when an application is shown inside a spreadsheet.
Parameters
Name | Type | Description |
---|---|---|
width | Integer | the new width value in pixels. |
Return
UiInstance
— the application itself, useful for chaining.