Home

# Class goog.ui.Prompt

Creates an object that represents a prompt (used in place of javascript's prompt). The html structure of the prompt is the same as the layout for dialog.js except for the addition of a text box which is placed inside the "Content area" and has the default class-name 'modal-dialog-userInput'

extends goog.ui.Dialog

Instance Method Summary
| `callback_()` Callback function which is invoked with the response to the prompt
| `createDom()` Create the initial DOM representation for the prompt.
| `disposeInternal()` Disposes of the component. Calls {@code exitDocument}, which is expected to remove event handlers and clean up the component. Propagates the call to the component's children, if any. Removes the component's DOM from the document unless it was decorated.
| `enterDocument()` Called when the component's element is known to be in the document. Anything using document.getElementById etc. should be done at this stage. If the component contains child components, this call is propagated to its children.
| `focus()` Overrides setFocus to put focus on the input element.
| `getCols() ⇒ number`
| `getRows() ⇒ number`
| `handleInputChanged_()` Handles input change events on the input field. Disables the OK button if validation fails on the new input value.
| `onPromptExit_(?goog.ui.Dialog.Event e)` Handles the closing of the prompt, invoking the callback function that was registered to handle the value returned by the prompt.
| `setCols(number cols)` Set the number of cols in the user input element.
| `setDefaultValue(string defaultValue)` Sets the default value of the prompt when it is displayed.
| `setInputDecoratorFn(function ((Element|null)): ? inputDecoratorFn)` Sets an input decorator function. This function will be called in #enterDocument and will be passed the input element. This is useful for attaching handlers to the input element for specific change events, for example.

`setRows(number rows)`

Set the number of rows in the user input element. A values of 1 means use an element. If the prompt is already rendered then you cannot change from to or vice versa.</p></td></tr><tr><td class="method-list-cell method-access method-public"></td><td class="method-list-cell method-cell"><code>setValidationFunction(function (string): boolean fn)</code><br><p class="method-description">Sets the validation function that takes a string and returns true if the string is accepted, false otherwise.</p></td></tr><tr><td class="method-list-cell method-access method-public"></td><td class="method-list-cell method-cell"><code>setVisible(boolean visible)</code><br><p class="method-description">Causes the prompt to appear, centered on the screen, gives focus to the text box, and selects the text</p></td></tr><tr><td class="method-list-cell method-access method-private"></td><td class="method-list-cell method-cell"><code>updateOkButtonState_()</code><br><p class="method-description">Set OK button enabled/disabled state based on input.</p></td></tr></table></body></html>