The goog.ui.SelectionMenuButton Class

goog.ui.SelectionMenuButton
> goog.ui.MenuButton
> goog.ui.Button
> goog.ui.Control
> goog.ui.Component
> goog.events.EventTarget
> goog.Disposable

goog.ui.SelectionMenuButton(opt_renderer, opt_itemRenderer, opt_domHelper)

A selection menu button control. Extends {@link goog.ui.MenuButton}. Menu contains 'select all' and 'select none' MenuItems for selecting all and no items by default. Other MenuItems can be added by user. The checkbox content fires the action events associated with the 'select all' and 'select none' menu items.

opt_renderer {goog.ui.ButtonRenderer=}
Renderer used to render or decorate the menu button; defaults to {@link goog.ui.MenuButtonRenderer}.
opt_itemRenderer {goog.ui.MenuItemRenderer=}
Optional menu item renderer.
opt_domHelper {goog.dom.DomHelper=}
Optional DOM hepler, used for document interaction.

The goog.ui.SelectionMenuButton.SelectionState Enum

Constants for menu action types. … more

.addChild(child, opt_render)

Inherited from goog.ui.Component .

Adds the specified component as the last child of this component. See {@link goog.ui.Component#addChildAt} for detailed semantics.

child {goog.ui.Component}
The new child component.
opt_render {boolean=}
If true, the child component will be rendered into the parent.
@see
goog.ui.Component#addChildAt

.addChildAt(child, index, opt_render)

Inherited from goog.ui.Component .

Adds the specified component as a child of this component at the given 0-based index. Both {@code addChild} and {@code addChildAt} assume the following contract between parent and child components:

In particular, {@code parent.addChild(child)} will throw an error if the child component is already in the document, but the parent isn't. Clients of this API may call {@code addChild} and {@code addChildAt} with {@code opt_render} set to true. If {@code opt_render} is true, calling these methods will automatically render the child component's element into the parent component's element. However, {@code parent.addChild(child, true)} will throw an error if: If {@code opt_render} is true and the parent component is not already in the document, {@code enterDocument} will not be called on this component at this point. Finally, this method also throws an error if the new child already has a different parent, or the given index is out of bounds.
child {goog.ui.Component}
The new child component.
index {number}
0-based index at which the new child component is to be added; must be between 0 and the current child count (inclusive).
opt_render {boolean=}
If true, the child component will be rendered into the parent.
returns {void}
Nada.
@see
goog.ui.Component#addChild

.addClassName(className)

Inherited from goog.ui.Control .

Adds the given class name to the list of classes to be applied to the component's root element.

className {string}
Additional class name to be applied to the component's root element.

.addEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched. Supported for legacy but use goog.events.listen(src, type, handler) instead.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.addItem(item)

Inherited from goog.ui.MenuButton .

Adds a new menu item at the end of the menu.

item {goog.ui.MenuItem|goog.ui.MenuSeparator|goog.ui.Control}
Menu item to add to the menu.

.addItemAt(item, index)

Inherited from goog.ui.MenuButton .

Adds a new menu item at the specific index in the menu.

item {goog.ui.MenuItem|goog.ui.MenuSeparator}
Menu item to add to the menu.
index {number}
Index at which to insert the menu item.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.canDecorate(element)

Inherited from goog.ui.Control .

Returns true if the given element can be decorated by this component. Overrides {@link goog.ui.Component#canDecorate}.

element {Element}
Element to decorate.
returns {boolean}
Whether the element can be decorated by this component.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.decorate(element)

Inherited from goog.ui.Component .

Decorates the element for the UI component.

element {Element}
Element to decorate.

.decorateInternal()

.dispatchEvent(e)

Inherited from goog.events.EventTarget .

Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object. If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.

e {string|Object|goog.events.Event}
Event object.
returns {boolean}
If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.

.dispose()

Inherited from goog.Disposable .

Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.

returns {void}
Nothing.

.enableClassName(className, enable)

Inherited from goog.ui.Control .

Adds or removes the given class name to/from the list of classes to be applied to the component's root element.

className {string}
CSS class name to add or remove.
enable {boolean}
Whether to add or remove the class name.

.enterDocument()

Inherited from goog.ui.MenuButton .

Sets up event handlers specific to menu buttons.

.exitDocument()

Inherited from goog.ui.MenuButton .

Removes event handlers specific to menu buttons, and ensures that the attached menu also exits the document.

.forEachChild(f, opt_obj)

Inherited from goog.ui.Component .

Calls the given function on each of this component's children in order. If {@code opt_obj} is provided, it will be used as the 'this' object in the function when called. The function should take two arguments: the child component and its 0-based index. The return value is ignored.

f {Function}
The function to call for every child component; should take 2 arguments (the child and its index).
opt_obj {Object=}
Used as the 'this' object in f when called.

.getCaption()

Inherited from goog.ui.Control .

returns {string}
Text caption of the control or empty string if none.

.getChild(id)

Inherited from goog.ui.Component .

Returns the child with the given ID, or null if no such child exists.

id {string}
Child component ID.
returns {goog.ui.Component?}
The child with the given ID; null if none.

.getChildAt(index)

Inherited from goog.ui.Component .

Returns the child at the given index, or null if the index is out of bounds.

index {number}
0-based index.
returns {goog.ui.Component?}
The child at the given index; null if none.

.getChildCount()

Inherited from goog.ui.Component .

Returns the number of children of this component.

returns {number}
The number of children.

.getChildIds()

Inherited from goog.ui.Component .

Returns an array containing the IDs of the children of this component, or an empty array if the component has no children.

returns {Array.<string>}
Child component IDs.

.getContent()

Inherited from goog.ui.Control .

Returns the text caption or DOM structure displayed in the component.

returns {goog.ui.ControlContent}
Text caption or DOM structure comprising the component's contents.

.getContentElement()

Inherited from goog.ui.Control .

Returns the DOM element into which child components are to be rendered, or null if the control itself hasn't been rendered yet. Overrides {@link goog.ui.Component#getContentElement} by delegating to the renderer.

returns {Element}
Element to contain child elements (null if none).

.getDomHelper()

Inherited from goog.ui.Component .

Returns the dom helper that is being used on this component.

returns {!goog.dom.DomHelper}
The dom helper used on this component.

.getElement()

Inherited from goog.ui.Component .

Gets the component's element.

returns {Element}
The element for the component.

.getElementByClass(className)

Inherited from goog.ui.Component .

Returns the first element in this component's DOM with the provided className.

className {string}
The name of the class to look for.
returns {Element}
The first item with the class name provided.

.getElementByFragment(idFragment)

Inherited from goog.ui.Component .

Helper function for returning an element in the document with a unique id generated using makeId().

idFragment {string}
The partial id.
returns {Element}
The element with the unique id, or null if it cannot be found.

.getElementsByClass(className)

Inherited from goog.ui.Component .

Returns an array of all the elements in this component's DOM with the provided className.

className {string}
The name of the class to look for.
returns {!goog.array.ArrayLike}
The items found with the class name provided.

.getExtraClassNames()

Inherited from goog.ui.Control .

Returns any additional class name(s) to be applied to the component's root element, or null if no extra class names are needed.

returns {Array.<string>?}
Additional class names to be applied to the component's root element (null if none).

.getFragmentFromId(id)

Inherited from goog.ui.Component .

Helper function for returning the fragment portion of an id generated using makeId().

id {string}
Id generated with makeId().
returns {string}
Fragment.

.getId()

Inherited from goog.ui.Component .

Gets the unique ID for the instance of this component. If the instance doesn't already have an ID, generates one on the fly.

returns {string}
Unique component ID.

.getItemAt(index)

Inherited from goog.ui.MenuButton .

Returns the menu item at a given index.

index {number}
Index of menu item.
returns {goog.ui.MenuItem?}
Menu item (null if not found).

.getItemCount()

Inherited from goog.ui.MenuButton .

Returns the number of items in the menu (including separators).

returns {number}
The number of items in the menu.

.getKeyEventTarget()

Inherited from goog.ui.Control .

Returns the DOM element on which the control is listening for keyboard events (null if none).

returns {Element}
Element on which the control is listening for key events.

.getMenu()

Inherited from goog.ui.MenuButton .

Returns the menu attached to the button. If no menu is attached, creates a new empty menu.

returns {goog.ui.Menu}
Popup menu attached to the menu button.

.getModel()

Inherited from goog.ui.Component .

Returns the model associated with the UI component.

returns {*}
The model.

.getParent()

Inherited from goog.ui.Component .

Returns the component's parent, if any.

returns {goog.ui.Component?}
The parent component.

.getParentEventTarget()

Inherited from goog.events.EventTarget .

Returns the parent of this event target to use for bubbling.

returns {goog.events.EventTarget}
The parent EventTarget or null if there is no parent.

.getPreferredAriaRole()

Inherited from goog.ui.Control .

Returns the control's preferred ARIA role. This can be used by a control to override the role that would be assigned by the renderer. This is useful in cases where a different ARIA role is appropriate for a control because of the context in which it's used. E.g., a {@link goog.ui.MenuButton} added to a {@link goog.ui.Select} should have an ARIA role of LISTBOX and not MENUITEM.

returns {?goog.dom.a11y.Role}
This control's preferred ARIA role or null if no preferred ARIA role is set.

.getRenderer()

Inherited from goog.ui.Control .

Returns the renderer used by this component to render itself or to decorate an existing element.

returns {goog.ui.ControlRenderer|undefined}
Renderer used by the component (undefined if none).

.getSelectionState()

Get selection state.

returns {goog.ui.SelectionMenuButton.SelectionState}
Selection state.

.getState()

Inherited from goog.ui.Control .

Returns the component's state as a bit mask of {@link goog.ui.Component.State}s.

returns {number}
Bit mask representing component state.

.getTooltip()

Inherited from goog.ui.Button .

Returns the tooltip for the button.

returns {string|undefined}
Tooltip text (undefined if none).

.getValue()

Inherited from goog.ui.Button .

Returns the value associated with the button.

returns {*}
Button value (undefined if none).

.handleContextMenu

Inherited from goog.ui.Control .

Handles contextmenu events.

e {goog.events.BrowserEvent}
Event to handle.

.handleDblClick(e)

Inherited from goog.ui.Control .

Handles dblclick events. Should only be registered if the user agent is IE. If the component is enabled, performs its associated action by calling {@link performActionInternal}. This is used to allow more performant buttons in IE. In IE, no mousedown event is fired when that mousedown will trigger a dblclick event. Because of this, a user clicking quickly will only cause ACTION events to fire on every other click. This is a workaround to generate ACTION events for every click. Unfortunately, this workaround won't ever trigger the ACTIVE state. This is roughly the same behaviour as if this were a 'button' element with a listener on mouseup. Considered protected; should only be used within this package and by subclasses.

e {goog.events.Event}
Mouse event to handle.

.handleFocus(e)

Inherited from goog.ui.Control .

Handles focus events on the component's key event target element. If the component is focusable, updates its state and styling to indicate that it now has keyboard focus. Considered protected; should only be used within this package and by subclasses. Warning: IE dispatches focus and blur events asynchronously!

e {goog.events.Event}
Focus event to handle.

.handleHighlightItem(e)

Inherited from goog.ui.MenuButton .

Handles {@code HIGHLIGHT} events dispatched by the attached menu.

e {goog.events.Event}
Highlight event to handle.

.handleKeyEvent(e)

Inherited from goog.ui.Control .

Attempts to handle a keyboard event, if the component is enabled and visible, by calling {@link handleKeyEventInternal}. Considered protected; should only be used within this package and by subclasses.

e {goog.events.KeyEvent}
Key event to handle.
returns {boolean}
Whether the key event was handled.

.handleMenuBlur(e)

Inherited from goog.ui.MenuButton .

Handles {@code BLUR} events dispatched by the popup menu by closing it. Only registered if the menu is focusable.

e {goog.events.Event}
Blur event dispatched by a focusable menu.

.handleMouseOut(e)

Inherited from goog.ui.Control .

Handles mouseout events. Dispatches a LEAVE event; if the event isn't canceled, and the component supports auto-highlighting, deactivates and un-highlights the component. Considered protected; should only be used within this package and by subclasses.

e {goog.events.BrowserEvent}
Mouse event to handle.

.handleMouseOver(e)

Inherited from goog.ui.Control .

Handles mouseover events. Dispatches an ENTER event; if the event isn't canceled, the component is enabled, and it supports auto-highlighting, highlights the component. Considered protected; should only be used within this package and by subclasses.

e {goog.events.BrowserEvent}
Mouse event to handle.

.handleUnHighlightItem(e)

Inherited from goog.ui.MenuButton .

Handles UNHIGHLIGHT events dispatched by the associated menu.

e {goog.events.Event}
Unhighlight event to handle.

.hasChildren()

Inherited from goog.ui.Component .

Returns true if the component has children.

returns {boolean}
True if the component has children.

.hasState(state)

Inherited from goog.ui.Control .

Returns true if the component is in the specified state, false otherwise.

state {goog.ui.Component.State}
State to check.
returns {boolean}
Whether the component is in the given state.

.indexOfChild(child)

Inherited from goog.ui.Component .

Returns the 0-based index of the given child component, or -1 if no such child is found.

child {goog.ui.Component?}
The child component.
returns {number}
0-based index of the child component; -1 if not found.

.invalidateMenuSize()

Inherited from goog.ui.MenuButton .

Resets the MenuButton's size. This is useful for cases where items are added or removed from the menu and scrollOnOverflow is on. In those cases the menu will not behave correctly and resize itself unless this is called (usually followed by positionMenu()).

.isActive()

Inherited from goog.ui.Control .

Returns true if the component is active (pressed), false otherwise.

returns {boolean}
Whether the component is active.

.isAlignMenuToStart()

Inherited from goog.ui.MenuButton .

returns {boolean}
Whether the menu is aligned to the start of the button (left if the render direction is left-to-right, right if the render direction is right-to-left).

.isAllowTextSelection()

Inherited from goog.ui.Control .

Returns true if the control allows text selection within its DOM, false otherwise. Controls that disallow text selection have the appropriate unselectable styling applied to their elements. Note that controls hosted in containers will report that they allow text selection even if their container disallows text selection.

returns {boolean}
Whether the control allows text selection.

.isAutoState(state)

Inherited from goog.ui.Control .

Returns true if the component provides default event handling for the state, false otherwise.

state {goog.ui.Component.State}
State to check.
returns {boolean}
Whether the component provides default event handling for the state.

.isChecked()

Inherited from goog.ui.Control .

Returns true if the component is checked, false otherwise.

returns {boolean}
Whether the component is checked.

.isDispatchTransitionEvents(state)

Inherited from goog.ui.Control .

Returns true if the component is set to dispatch transition events for the given state, false otherwise.

state {goog.ui.Component.State}
State to check.
returns {boolean}
Whether the component dispatches transition events for the state.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.isEnabled()

Inherited from goog.ui.Control .

Returns true if the component is enabled, false otherwise.

returns {boolean}
Whether the component is enabled.

.isFocusablePopupMenu()

Inherited from goog.ui.MenuButton .

returns {boolean}
Whether the attached menu is focusable.

.isFocused()

Inherited from goog.ui.Control .

Returns true if the component is styled to indicate that it has keyboard focus, false otherwise. Note that {@code isFocused()} returning true doesn't guarantee that the component's key event target has keyborad focus, only that it is styled as such.

returns {boolean}
Whether the component is styled to indicate as having keyboard focus.

.isHandleMouseEvents()

Inherited from goog.ui.Control .

Returns true if the control is configured to handle its own mouse events, false otherwise. Controls not hosted in {@link goog.ui.Container}s have to handle their own mouse events, but controls hosted in containers may allow their parent to handle mouse events on their behalf. Considered protected; should only be used within this package and by subclasses.

returns {boolean}
Whether the control handles its own mouse events.

.isHighlighted()

Inherited from goog.ui.Control .

Returns true if the component is currently highlighted, false otherwise.

returns {boolean}
Whether the component is highlighted.

.isInDocument()

Inherited from goog.ui.Component .

Determines whether the component has been added to the document.

returns {boolean}
TRUE if rendered. Otherwise, FALSE.

.isOpen()

Inherited from goog.ui.Control .

Returns true if the component is open (expanded), false otherwise.

returns {boolean}
Whether the component is open.

.isRightToLeft()

Inherited from goog.ui.Component .

Returns true if the component is rendered right-to-left, false otherwise. The first time this function is invoked, the right-to-left rendering property is set if it has not been already.

returns {boolean}
Whether the control is rendered right-to-left.

.isScrollOnOverflow()

Inherited from goog.ui.MenuButton .

returns {boolean}
Wether the menu will scroll when it's to big to fit vertically on the screen.

.isSelected()

Inherited from goog.ui.Control .

Returns true if the component is selected, false otherwise.

returns {boolean}
Whether the component is selected.

.isSupportedState(state)

Inherited from goog.ui.Control .

Returns true if the component supports the specified state, false otherwise.

state {goog.ui.Component.State}
State to check.
returns {boolean}
Whether the component supports the given state.

.isVisible()

Inherited from goog.ui.Control .

Returns true if the component's visibility is set to visible, false if it is set to hidden. A component that is set to hidden is guaranteed to be hidden from the user, but the reverse isn't necessarily true. A component may be set to visible but can otherwise be obscured by another element, rendered off-screen, or hidden using direct CSS manipulation.

returns {boolean}
Whether the component is visible.

.makeId(idFragment)

Inherited from goog.ui.Component .

Helper function for subclasses that gets a unique id for a given fragment, this can be used by components to generate unique string ids for DOM elements.

idFragment {string}
A partial id.
returns {string}
Unique element id.

.makeIds(object)

Inherited from goog.ui.Component .

Makes a collection of ids. This is a convenience method for makeId. The object's values are the id fragments and the new values are the generated ids. The key will remain the same.

object {Object}
The object that will be used to create the ids.
returns {Object}
An object of id keys to generated ids.

.positionMenu()

Inherited from goog.ui.MenuButton .

Positions the menu under the button. May be called directly in cases when the menu size is known to change.

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.removeChild(child, opt_unrender)

Inherited from goog.ui.Component .

Removes the given child from this component, and returns it. Throws an error if the argument is invalid or if the specified child isn't found in the parent component. The argument can either be a string (interpreted as the ID of the child component to remove) or the child component itself. If {@code opt_unrender} is true, calls {@link goog.ui.component#exitDocument} on the removed child, and subsequently detaches the child's DOM from the document. Otherwise it is the caller's responsibility to clean up the child component's DOM.

child {string|goog.ui.Component|null}
The ID of the child to remove, or the child component itself.
opt_unrender {boolean=}
If true, calls {@code exitDocument} on the removed child component, and detaches its DOM from the document.
returns {goog.ui.Component}
The removed component, if any.
@see
goog.ui.Component#removeChildAt

.removeChildAt(index, opt_unrender)

Inherited from goog.ui.Component .

Removes the child at the given index from this component, and returns it. Throws an error if the argument is out of bounds, or if the specified child isn't found in the parent. See {@link goog.ui.Component#removeChild} for detailed semantics.

index {number}
0-based index of the child to remove.
opt_unrender {boolean=}
If true, calls {@code exitDocument} on the removed child component, and detaches its DOM from the document.
returns {goog.ui.Component}
The removed component, if any.
@see
goog.ui.Component#removeChild

.removeChildren(opt_unrender)

Inherited from goog.ui.Component .

Removes every child component attached to this one and returns them.

opt_unrender {boolean=}
If true, calls {@link #exitDocument} on the removed child components, and detaches their DOM from the document.
returns {!Array.<goog.ui.Component>|undefined}
The removed components if any.
@see
goog.ui.Component#removeChild

.removeClassName(className)

Inherited from goog.ui.Control .

Removes the given class name from the list of classes to be applied to the component's root element.

className {string}
Class name to be removed from the component's root element.

.removeEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.removeItem(item)

Inherited from goog.ui.MenuButton .

Removes the item from the menu and disposes of it.

item {goog.ui.MenuItem|goog.ui.MenuSeparator}
The menu item to remove.

.removeItemAt(index)

Inherited from goog.ui.MenuButton .

Removes the menu item at a given index in the menu and disposes of it.

index {number}
Index of item.

.render(opt_parentElement)

Inherited from goog.ui.Component .

Renders the component. If a parent element is supplied, the component's element will be appended to it. If there is no optional parent element and the element doesn't have a parentNode then it will be appended to the document body. If this component has a parent component, and the parent component is not in the document already, then this will not call {@code enterDocument} on this component. Throws an Error if the component is already rendered.

opt_parentElement {Element=}
Optional parent element to render the component into.

.renderBefore(sibling)

Inherited from goog.ui.Component .

Renders the component before another element. The other element should be in the document already. Throws an Error if the component is already rendered.

sibling {Node}
Node to render the component before.

.setActive(active)

Inherited from goog.ui.Control .

Activates or deactivates the component. Does nothing if this state transition is disallowed.

active {boolean}
Whether to activate or deactivate the component.
@see
#isTransitionAllowed

.setAlignMenuToStart(alignToStart)

Inherited from goog.ui.MenuButton .

Sets whether the menu is aligned to the start or the end of the button.

alignToStart {boolean}
Whether the menu is to be aligned to the start of the button (left if the render direction is left-to-right, right if the render direction is right-to-left).

.setAllowTextSelection(allow)

Inherited from goog.ui.Control .

Allows or disallows text selection within the control's DOM.

allow {boolean}
Whether the control should allow text selection.

.setAutoStates(states, enable)

Inherited from goog.ui.Control .

Enables or disables automatic event handling for the given state(s).

states {number}
Bit mask of {@link goog.ui.Component.State}s for which default event handling is to be enabled or disabled.
enable {boolean}
Whether the component should provide default event handling for the state(s).

.setCaption(caption)

Inherited from goog.ui.Control .

Sets the text caption of the component.

caption {string}
Text caption of the component.

.setChecked(check)

Inherited from goog.ui.Control .

Checks or unchecks the component. Does nothing if this state transition is disallowed.

check {boolean}
Whether to check or uncheck the component.
@see
#isTransitionAllowed

.setCollapsed(sides)

Inherited from goog.ui.Button .

Collapses the border on one or both sides of the button, allowing it to be combined with the adjancent button(s), forming a single UI componenet with multiple targets.

sides {number}
Bitmap of one or more {@link goog.ui.ButtonSide}s for which borders should be collapsed.

.setContent(content)

Inherited from goog.ui.Control .

Sets the component's content to the given text caption, element, or array of nodes. (If the argument is an array of nodes, it must be an actual array, not an array-like object.)

content {goog.ui.ControlContent}
Text caption or DOM structure to set as the component's contents.

.setDispatchTransitionEvents(states, enable)

Inherited from goog.ui.Control .

Enables or disables transition events for the given state(s). Controls handle state transitions internally by default, and only dispatch state transition events if explicitly requested to do so by calling this method.

states {number}
Bit mask of {@link goog.ui.Component.State}s for which transition events should be enabled or disabled.
enable {boolean}
Whether transition events should be enabled.

.setEnabled(enable)

Enables button and embedded checkbox.

enable {boolean}
Whether to enable or disable the button.

.setFocusablePopupMenu(focusable)

Inherited from goog.ui.MenuButton .

Sets whether the attached popup menu is focusable. If the popup menu is focusable, it may steal keyboard focus from the menu button, so the button will not hide the menu on blur.

focusable {boolean}
Whether the attached menu is focusable.

.setFocused(focused)

Inherited from goog.ui.Control .

Applies or removes styling indicating that the component has keyboard focus. Note that unlike the other "set" methods, this method is called as a result of the component's element having received or lost keyboard focus, not the other way around, so calling {@code setFocused(true)} doesn't guarantee that the component's key event target has keyboard focus, only that it is styled as such.

focused {boolean}
Whether to apply or remove styling to indicate that the component's element has keyboard focus.

.setHandleMouseEvents(enable)

Inherited from goog.ui.Control .

Enables or disables mouse event handling for the control. Containers may use this method to disable mouse event handling in their child controls. Considered protected; should only be used within this package and by subclasses.

enable {boolean}
Whether to enable or disable mouse event handling.

.setHighlighted(highlight)

Inherited from goog.ui.Control .

Highlights or unhighlights the component. Does nothing if this state transition is disallowed.

highlight {boolean}
Whether to highlight or unhighlight the component.
@see
#isTransitionAllowed

.setId(id)

Inherited from goog.ui.Component .

Assigns an ID to this component instance. It is the caller's responsibility to guarantee that the ID is unique. If the component is a child of a parent component, then the parent component's child index is updated to reflect the new ID; this may throw an error if the parent already has a child with an ID that conflicts with the new ID.

id {string}
Unique component ID.

.setMenu(menu)

Replaces the menu attached to the button with the argument, and returns the previous menu (if any).

menu {goog.ui.Menu?}
New menu to be attached to the menu button (null to remove the menu).
returns {goog.ui.Menu|undefined}
Previous menu (undefined if none).

.setMenuMargin(margin)

Inherited from goog.ui.MenuButton .

Sets a margin that will be applied to the menu's position when it is shown. If null, no margin will be applied.

margin {goog.math.Box}
Margin to apply.

.setMenuPosition(position)

Inherited from goog.ui.MenuButton .

Specify which positioning algorithm to use. This method is preferred over the fine-grained positioning methods like setPositionElement, setAlignMenuToStart, and setScrollOnOverflow. Calling this method will override settings by those methods.

position {goog.positioning.AnchoredPosition}
The position of the Menu the button. If the position has a null anchor, we will use the menubutton element as the anchor.

.setModel(obj)

Inherited from goog.ui.Component .

Sets the model associated with the UI component.

obj {*}
The model.

.setOpen(open, opt_e)

Inherited from goog.ui.MenuButton .

Opens or closes the attached popup menu.

open {boolean}
Whether to open or close the menu.
opt_e {goog.events.Event=}
Mousedown event that caused the menu to be opened.

.setParent(parent)

Inherited from goog.ui.Component .

Sets the parent of this component to use for event bubbling. Throws an error if the component already has a parent or if an attempt is made to add a component to itself as a child. Callers must use {@code removeChild} or {@code removeChildAt} to remove components from their containers before calling this method.

parent {goog.ui.Component}
The parent component.
@see
goog.ui.Component#removeChild
@see
goog.ui.Component#removeChildAt

.setParentEventTarget(parent)

Inherited from goog.ui.Component .

Overrides {@link goog.events.EventTarget#setParentEventTarget} to throw an error if the parent component is set, and the argument is not the parent.

parent {goog.events.EventTarget?}
Parent EventTarget (null if none).

.setPositionElement(positionElement)

Inherited from goog.ui.MenuButton .

Sets an element for anchoring the menu.

positionElement {Element}
New element to use for positioning the dropdown menu. Null to use the default behavior of positioning to this menu button.

.setPreferredAriaRole(role)

Inherited from goog.ui.Control .

Sets the control's preferred ARIA role. This can be used to override the role that would be assigned by the renderer. This is useful in cases where a different ARIA role is appropriate for a control because of the context in which it's used. E.g., a {@link goog.ui.MenuButton} added to a {@link goog.ui.Select} should have an ARIA role of LISTBOX and not MENUITEM.

role {goog.dom.a11y.Role}
This control's preferred ARIA role.

.setRenderMenuAsSibling(renderMenuAsSibling)

Inherited from goog.ui.MenuButton .

Sets whether to render the menu as a sibling element of the button. Normally, the menu is a child of document.body. This option is useful if you need the menu to inherit styles from a common parent element, or if you otherwise need it to share a parent element for desired event handling. One example of the latter is if the parent is in a goog.ui.Popup, to ensure that clicks on the menu are considered being within the popup.

renderMenuAsSibling {boolean}
Whether we render the menu at the end of the dom or as a sibling to the button/label that renders the drop down.

.setRenderer(renderer)

Inherited from goog.ui.Control .

Registers the given renderer with the component. Changing renderers after the component has entered the document is an error.

renderer {goog.ui.ControlRenderer}
Renderer used by the component.
@throws
{Error} If the control is already in the document.

.setRightToLeft(rightToLeft)

Inherited from goog.ui.Control .

Set is right-to-left. This function should be used if the component needs to know the rendering direction during dom creation (i.e. before {@link #enterDocument} is called and is right-to-left is set).

rightToLeft {boolean}
Whether the component is rendered right-to-left.

.setScrollOnOverflow(scrollOnOverflow)

Inherited from goog.ui.MenuButton .

Sets whether the menu should scroll when it's too big to fix vertically on the screen. The css of the menu element should have overflow set to auto. Note: Adding or removing items while the menu is open will not work correctly if scrollOnOverflow is on.

scrollOnOverflow {boolean}
Whether the menu should scroll when too big to fit on the screen. If false, adjust logic will be used to try and reposition the menu to fit.

.setSelected(select)

Inherited from goog.ui.Control .

Selects or unselects the component. Does nothing if this state transition is disallowed.

select {boolean}
Whether to select or unselect the component.
@see
#isTransitionAllowed

.setSelectionState(state)

Set selection state and update checkbox.

state {goog.ui.SelectionMenuButton.SelectionState}
Selection state.

.setState(state, enable)

Inherited from goog.ui.Control .

Sets or clears the given state on the component, and updates its styling accordingly. Does nothing if the component is already in the correct state or if it doesn't support the specified state. Doesn't dispatch any state transition events; use advisedly.

state {goog.ui.Component.State}
State to set or clear.
enable {boolean}
Whether to set or clear the state (if supported).

.setSupportedState(state, support)

Inherited from goog.ui.Control .

Enables or disables support for the given state. Disabling support for a state while the component is in that state is an error.

state {goog.ui.Component.State}
State to support or de-support.
support {boolean}
Whether the component should support the state.
@throws
{Error} If disabling support for a state the control is currently in.

.setTooltip(tooltip)

Inherited from goog.ui.Button .

Sets the tooltip for the button, and updates its DOM.

tooltip {string}
New tooltip text.

.setValue(value)

Inherited from goog.ui.Button .

Sets the value associated with the button, and updates its DOM.

value {*}
New button value.

.setVisible(visible, opt_force)

Inherited from goog.ui.MenuButton .

Shows/hides the menu button based on the value of the argument. Also hides the popup menu if the button is being hidden.

visible {boolean}
Whether to show or hide the button.
opt_force {boolean=}
If true, doesn't check whether the component already has the requested visibility, and doesn't dispatch any events.
returns {boolean}
Whether the visibility was changed.

.wasDecorated()

Inherited from goog.ui.Component .

returns {boolean}
Whether the component was decorated.