goog.ui.MenuItem
Provided By | |
---|---|
Extends | |
All Implemented Interfaces | |
All Known Direct Subclasses |
Class representing an item in a menu.
new MenuItem( content, opt_model, opt_domHelper, opt_renderer )
Parameters |
|
---|
Instance Methods
this.addChild( child, opt_render ) → void
void
Adds the specified component as the last child of this component. See
goog.ui.Component#addChildAt
for detailed semantics.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
See Also |
this.addChildAt( child, index, opt_render ) → ?
?
Adds the specified component as a child of this component at the given 0-based index.
Both addChild
and addChildAt
assume the following contract
between parent and child components:
- the child component's element must be a descendant of the parent component's element, and
- the DOM state of the child component must be consistent with the DOM state of the parent component (see `isInDocument`) in the steady state -- the exception is to addChildAt(child, i, false) and then immediately decorate/render the child.
In particular, 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 addChild
and addChildAt
with
opt_render
set to true. If opt_render
is true, calling these
methods will automatically render the child component's element into the
parent component's element. If the parent does not yet have an element, then
createDom
will automatically be invoked on the parent before
rendering the child.
Invoking parent.addChild(child, true)
will throw an error if the
child component is already in the document, regardless of the parent's DOM
state.
If opt_render
is true and the parent component is not already
in the document, 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.
Defined by | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||||||
Returns |
| ||||||||||||
See Also |
this.addClassName( className ) → void
void
Adds the given class name to the list of classes to be applied to the component's root element.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.addEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
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.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.addOnDisposeCallback<T>( callback, opt_scope ) → void
void
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.canDecorate( element ) → boolean
boolean
Returns true if the given element can be decorated by this component.
Overrides goog.ui.Component#canDecorate
.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
| ||||
Returns |
|
this.createDom() → void
void
Creates the control's DOM. Overrides goog.ui.Component#createDom
by
delegating DOM manipulation to the control's renderer.
Defined by | |
---|---|
Overrides | |
Parameters | None. |
this.decorate( element ) → void
void
Decorates the element for the UI component. If the element is in the document, the enterDocument method will be called.
If goog.ui.Component.ALLOW_DETACHED_DECORATION is false, the caller must pass an element that is in the document.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.decorateInternal( element ) → void
void
Decorates the given element with this component. Overrides goog.ui.Component#decorateInternal
by delegating DOM manipulation
to the control's renderer.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
|
this.dispatchEvent( e ) → boolean
boolean
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.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.dispose() → ?
?
Disposes of the object and its resources.
Overrides | ||
---|---|---|
Specified by | ||
Parameters | None. | |
Returns |
|
this.disposeInternal() → void
void
Disposes of the component. Calls 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.
Defined by | |
---|---|
Overrides | |
Parameters | None. |
this.enableClassName( className, enable ) → void
void
this.enterDocument() → void
void
Configures the component after its DOM has been rendered, and sets up event
handling. Overrides goog.ui.Component#enterDocument
.
Defined by | |
---|---|
Overrides | |
Parameters | None. |
this.exitDocument() → void
void
Cleans up the component before its DOM is removed from the document, and
removes event handlers. Overrides goog.ui.Component#exitDocument
by making sure that components that are removed from the document aren't
focusable (i.e. have no tab index).
Defined by | |
---|---|
Overrides | |
Parameters | None. |
this.fireListeners<EVENTOBJ>( type, capture, eventObject ) → boolean
boolean
Fires all registered listeners in this listenable for the given type and capture mode, passing them the given eventObject. This does not perform actual capture/bubble. Only implementors of the interface should be using this.
Overrides | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||
Parameters |
| ||||||||||||
Returns |
|
this.forEachChild<T>( f, opt_obj ) → void
void
Calls the given function on each of this component's children in order. If
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.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.getAccelerator() → (string|null)
(string|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getAriaLabel() → (string|null)
(string|null)
Gets the control's aria label.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getCaption() → string
string
Returns the text caption of the component while ignoring accelerators.
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getChild( id ) → (goog.ui.Component|null)
(goog.ui.Component|null)
Returns the child with the given ID, or null if no such child exists.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getChildAt( index ) → (goog.ui.Component|null)
(goog.ui.Component|null)
Returns the child at the given index, or null if the index is out of bounds.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getChildCount() → number
number
Returns the number of children of this component.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getContentElement() → (Element|null)
(Element|null)
Returns the DOM element into which child components are to be rendered,
or null if the control itself hasn't been rendered yet. Overrides
goog.ui.Component#getContentElement
by delegating to the renderer.
Defined by | |||
---|---|---|---|
Overrides | |||
Parameters | None. | ||
Returns |
|
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getDomHelper() → goog.dom.DomHelper
goog.dom.DomHelper
Returns the dom helper that is being used on this component.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getElement() → (Element|null)
(Element|null)
Gets the component's element.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getElementByClass( className ) → (Element|null)
(Element|null)
Returns the first element in this component's DOM with the provided className.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getElementByFragment( idFragment ) → (Element|null)
(Element|null)
Helper function for returning an element in the document with a unique id generated using makeId().
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getElementStrict() → Element
Element
Gets the component's element. This differs from getElement in that it assumes that the element exists (i.e. the component has been rendered/decorated) and will cause an assertion error otherwise (if assertion is enabled).
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getElementsByClass( className ) → IArrayLike<Element>
IArrayLike<Element>
Returns an array of all the elements in this component's DOM with the provided className.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getFragmentFromId( id ) → string
string
this.getHandler<T>() → goog.events.EventHandler<(T|null)>
goog.events.EventHandler<(T|null)>
Returns the event handler for this component, lazily created the first time this method is called.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getId() → string
string
Gets the unique ID for the instance of this component. If the instance doesn't already have an ID, generates one on the fly.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getKeyEventTarget() → (Element|null)
(Element|null)
Returns the DOM element on which the control is listening for keyboard events (null if none).
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getKeyHandler() → goog.events.KeyHandler
goog.events.KeyHandler
Returns the keyboard event handler for this component, lazily created the first time this method is called. Considered protected; should only be used within this package and by subclasses.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getListener<SCOPE, EVENTOBJ>( type, listener, capture, opt_listenerScope ) → (goog.events.ListenableKey|null)
(goog.events.ListenableKey|null)
Gets the goog.events.ListenableKey for the event or null if no such listener is in use.
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.getListeners<EVENTOBJ>( type, capture ) → Array<goog.events.ListenableKey>
Array<goog.events.ListenableKey>
Gets all listeners in this listenable for the given type and capture mode.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.getMnemonic() → goog.events.KeyCodes
goog.events.KeyCodes
Gets the mnemonic key code. The mnemonic is the key associated with this action.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getModel() → *
*
Returns the model associated with the UI component.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getParent() → (goog.ui.Menu|null)
(goog.ui.Menu|null)
Returns the component's parent, if any.
Overrides | ||
---|---|---|
Parameters | None. | |
Returns |
|
this.getParentEventTarget() → (goog.ui.Menu|null)
(goog.ui.Menu|null)
Returns the parent of this event target to use for capture/bubble mechanism.
NOTE(chrishenry): The name reflects the original implementation of
custom event target (goog.events.EventTarget
). We decided
that changing the name is not worth it.
Overrides | ||
---|---|---|
Specified by | ||
Parameters | None. | |
Returns |
|
this.getPreferredAriaRole() → (goog.a11y.aria.Role|null)
(goog.a11y.aria.Role|null)
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 goog.ui.MenuButton
added to a
goog.ui.Select
should have an ARIA role of LISTBOX and not MENUITEM.
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getRenderer() → (goog.ui.ControlRenderer|null|undefined)
(goog.ui.ControlRenderer|null|undefined)
Returns the renderer used by this component to render itself or to decorate an existing element.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getRequiredElementByClass( className ) → Element
Element
Similar to getElementByClass
except that it expects the
element to be present in the dom thus returning a required value. Otherwise,
will assert.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getState() → number
number
Returns the component's state as a bit mask of goog.ui.Component.State
s.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getValue() → *
*
Returns the value associated with the menu item. The default implementation returns the model object associated with the item (if any), or its caption.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.handleBlur( e ) → void
void
Handles blur events on the component's key event target element. Always deactivates the component. In addition, if the component is focusable, updates its state and styling to indicate that it no longer has keyboard focus. Considered protected; should only be used within this package and by subclasses. Warning: IE dispatches focus and blur events asynchronously!
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleContextMenu( e ) → void
void
Handles contextmenu events.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleDblClick( e ) → void
void
Handles dblclick events. Should only be registered if the user agent is
IE. If the component is enabled, performs its associated action by calling
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.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleFocus( e ) → void
void
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!
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleKeyEvent( e ) → boolean
boolean
Attempts to handle a keyboard event, if the component is enabled and visible,
by calling handleKeyEventInternal
. Considered protected; should only
be used within this package and by subclasses.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.handleKeyEventInternal( e ) → boolean
boolean
Attempts to handle a keyboard event; returns true if the event was handled, false otherwise. Considered protected; should only be used within this package and by subclasses.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.handleMouseDown( e ) → void
void
Handles mousedown events. If the component is enabled, highlights and activates it. If the component isn't configured for keyboard access, prevents it from receiving keyboard focus. Considered protected; should only be used within this package and by subclasses.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleMouseOut( e ) → void
void
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.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleMouseOver( e ) → void
void
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.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleMouseUp( e ) → void
void
Handles mouseup events. If the component is enabled, highlights it. If
the component has previously been activated, performs its associated action
by calling performActionInternal
, then deactivates it. Considered
protected; should only be used within this package and by subclasses.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.hasChildren() → boolean
boolean
Returns true if the component has children.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.hasListener<EVENTOBJ>( opt_type, opt_capture ) → boolean
boolean
Whether there is any active listeners matching the specified signature. If either the type or capture parameters are unspecified, the function will match on the remaining criteria.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.hasState( state ) → boolean
boolean
Returns true if the component is in the specified state, false otherwise.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.indexOfChild( child ) → number
number
Returns the 0-based index of the given child component, or -1 if no such child is found.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.isActive() → boolean
boolean
Returns true if the component is active (pressed), false otherwise.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isAllowTextSelection() → boolean
boolean
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.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isAutoState( state ) → boolean
boolean
Returns true if the component provides default event handling for the state, false otherwise.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.isChecked() → boolean
boolean
Returns true if the component is checked, false otherwise.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isDispatchTransitionEvents( state ) → boolean
boolean
Returns true if the component is set to dispatch transition events for the given state, false otherwise.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.isEnabled() → boolean
boolean
Returns true if the component is enabled, false otherwise.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isFocused() → boolean
boolean
Returns true if the component is styled to indicate that it has keyboard
focus, false otherwise. Note that isFocused()
returning true
doesn't guarantee that the component's key event target has keyboard focus,
only that it is styled as such.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isHandleMouseEvents() → boolean
boolean
Returns true if the control is configured to handle its own mouse events,
false otherwise. Controls not hosted in 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.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isHighlighted() → boolean
boolean
Returns true if the component is currently highlighted, false otherwise.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isInDocument() → boolean
boolean
Determines whether the component has been added to the document.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isOpen() → boolean
boolean
Returns true if the component is open (expanded), false otherwise.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isRightToLeft() → boolean
boolean
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.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isSelected() → boolean
boolean
Returns true if the component is selected, false otherwise.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isSupportedState( state ) → boolean
boolean
Returns true if the component supports the specified state, false otherwise.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.isTransitionAllowed( state, enable ) → boolean
boolean
Returns true if the transition into or out of the given state is allowed to proceed, false otherwise. A state transition is allowed under the following conditions:
- the component supports the state,
- the component isn't already in the target state,
- either the component is configured not to dispatch events for this state transition, or a transition event was dispatched and wasn't canceled by any event listener, and
- the component hasn't been disposed of
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.isVisible() → boolean
boolean
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.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.listen<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener. A listener can only be added once to an object and if it is added again the key for the listener is returned. Note that if the existing listener is a one-off listener (registered via listenOnce), it will no longer be a one-off listener after a call to listen().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.listenOnce<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener that is removed automatically after the listener fired once.
If an existing listener already exists, listenOnce will do nothing. In particular, if the listener was previously registered via listen(), listenOnce() will not turn the listener into a one-off listener. Similarly, if there is already an existing one-off listener, listenOnce does not modify the listeners (it is still a once listener).
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.makeId( idFragment ) → string
string
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.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.performActionInternal( e ) → boolean
boolean
Performs the appropriate action when the control is activated by the user. The default implementation first updates the checked and selected state of controls that support them, then dispatches an ACTION event. Considered protected; should only be used within this package and by subclasses.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.pointerEventsEnabled() → boolean
boolean
Returns whether this component should listen for PointerEvent types rather than MouseEvent types. This allows supporting drag gestures for touch/stylus input.
Defined by | ||
---|---|---|
Parameters | None. | |
Returns |
|
this.registerDisposable( disposable ) → void
void
Associates a disposable object with this object so that they will be disposed together.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.removeAllListeners( opt_type ) → number
number
Removes all listeners from this listenable. If type is specified, it will only remove listeners of the particular type. otherwise all registered listeners will be removed.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.removeChild( child, opt_unrender ) → (goog.ui.Component|null)
(goog.ui.Component|null)
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 opt_unrender
is true, calls 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.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
| ||||||||
See Also |
this.removeChildAt( index, opt_unrender ) → (goog.ui.Component|null)
(goog.ui.Component|null)
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 goog.ui.Component#removeChild
for
detailed semantics.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
| ||||||||
See Also |
this.removeChildren( opt_unrender ) → Array<(goog.ui.Component|null)>
Array<(goog.ui.Component|null)>
Removes every child component attached to this one and returns them.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
| ||||
See Also |
this.removeClassName( className ) → void
void
Removes the given class name from the list of classes to be applied to the component's root element.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.removeEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
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.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.render( opt_parentElement ) → void
void
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 enterDocument
on this component.
Throws an Error if the component is already rendered.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.renderBefore( sibling ) → void
void
Renders the component before another element. The other element should be in the document already.
Throws an Error if the component is already rendered.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setActive( active ) → void
void
Activates or deactivates the component. Does nothing if this state transition is disallowed.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
See Also |
this.setAllowTextSelection( allow ) → void
void
Allows or disallows text selection within the control's DOM.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setAriaLabel( label ) → void
void
Sets the control's aria label. This can be used to assign aria label to the element after it is rendered.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setAutoStates( states, enable ) → void
void
Enables or disables automatic event handling for the given state(s).
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setCaption( caption ) → void
void
Sets the text caption of the component.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setCheckable( checkable ) → void
void
Sets the menu item to be checkable or not. Set to true for menu items that represent checkable options.
Parameters |
|
---|
this.setChecked( check ) → void
void
Checks or unchecks the component. Does nothing if this state transition is disallowed.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
See Also |
this.setContent( content ) → void
void
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.)
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setContentInternal( content ) → void
void
Sets the component's content to the given text caption, element, or array
of nodes. Unlike #setContent
, doesn't modify the component's DOM.
Called by renderers during element decoration.
This should only be used by subclasses and its associated renderers.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setDispatchTransitionEvents( states, enable ) → void
void
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.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setElementInternal( element ) → void
void
Sets the component's root element to the given element. Considered protected and final.
This should generally only be called during createDom. Setting the element does not actually change which element is rendered, only the element that is associated with this UI component.
This should only be used by subclasses and its associated renderers.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setEnabled( enable ) → void
void
Enables or disables the component. Does nothing if this state transition
is disallowed. If the component is both visible and focusable, updates its
focused state and tab index as needed. If the component is being disabled,
ensures that it is also deactivated and un-highlighted first. Note that the
component's enabled/disabled state is "locked" as long as it is hosted in a
goog.ui.Container
that is itself disabled; this is to prevent clients
from accidentally re-enabling a control that is in a disabled container.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
See Also |
this.setFocused( focused ) → void
void
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 setFocused(true)
doesn't guarantee that
the component's key event target has keyboard focus, only that it is styled
as such.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setHandleMouseEvents( enable ) → void
void
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.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setHighlighted( highlight ) → void
void
Highlights or unhighlights the component. Does nothing if this state transition is disallowed.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
See Also |
this.setId( id ) → void
void
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.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setMnemonic( key ) → void
void
Sets the mnemonic key code. The mnemonic is the key associated with this action.
Parameters |
|
---|
this.setModel( obj ) → void
void
Sets the model associated with the UI component.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setOpen( open ) → void
void
Opens (expands) or closes (collapses) the component. Does nothing if this state transition is disallowed.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
See Also |
this.setParent( parent ) → void
void
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 removeChild
or removeChildAt
to remove components from their containers before
calling this method.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
See Also |
this.setParentEventTarget( parent ) → void
void
Overrides goog.events.EventTarget#setParentEventTarget
to throw an
error if the parent component is set, and the argument is not the parent.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
|
this.setPointerEventsEnabled( enable ) → void
void
Indicates whether this component should listen for PointerEvent types rather than MouseEvent types. This allows supporting drag gestures for touch/stylus input. Must be called before enterDocument to listen for the correct event types.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setPreferredAriaRole( role ) → void
void
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 goog.ui.MenuButton
added to a
goog.ui.Select
should have an ARIA role of LISTBOX and not MENUITEM.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setRenderer( renderer ) → void
void
Registers the given renderer with the component. Changing renderers after the component has entered the document is an error.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Throws |
|
this.setRightToLeft( rightToLeft ) → void
void
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
#enterDocument
is called and is right-to-left is set).
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
|
this.setSelectable( selectable ) → void
void
Sets the menu item to be selectable or not. Set to true for menu items that represent selectable options.
Parameters |
|
---|
this.setSelected( select ) → void
void
Selects or unselects the component. Does nothing if this state transition is disallowed.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
See Also |
this.setState( state, enable, opt_calledFrom ) → void
void
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.
Defined by | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setStateInternal( state ) → void
void
Sets the component's state to the state represented by a bit mask of
goog.ui.Component.State
s. Unlike #setState
, doesn't
update the component's styling, and doesn't reject unsupported states.
Called by renderers during element decoration. Considered protected;
should only be used within this package and by subclasses.
This should only be used by subclasses and its associated renderers.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setSupportedState( state, support ) → void
void
Enables or disables support for the given state. Disabling support for a state while the component is in that state is an error.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setTargetForTesting( target ) → void
void
Sets the target to be used for event.target
when firing
event. Mainly used for testing. For example, see
goog.testing.events.mixinListenable
.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setValue( value ) → void
void
Sets the value associated with the menu item. The default implementation stores the value as the model of the menu item.
Parameters |
|
---|
this.setVisible( visible, opt_force ) → boolean
boolean
Shows or hides the component. Does nothing if the component already has the requested visibility. Otherwise, dispatches a SHOW or HIDE event as appropriate, giving listeners a chance to prevent the visibility change. When showing a component that is both enabled and focusable, ensures that its key target has a tab index. When hiding a component that is enabled and focusable, blurs its key target and removes its tab index.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.unlisten<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → boolean
boolean
Removes an event listener which was added with listen() or listenOnce().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.unlistenByKey( key ) → boolean
boolean
Removes an event listener which was added with listen() by the key returned by listen().
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.wasDecorated() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
Instance Properties
this.creationStack → (string|undefined)
(string|undefined)
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
this.dom_ → goog.dom.DomHelper
goog.dom.DomHelper
DomHelper used to interact with the document, allowing components to be created in a different window.
Static Properties
MenuItem.ACCELERATOR_CLASS → string
string
The class set on an element that contains a keyboard accelerator hint.