The goog.ui.FilteredMenu Class

goog.ui.FilteredMenu
> goog.ui.Menu
> goog.ui.Container
> goog.ui.Component
> goog.events.EventTarget
> goog.Disposable

goog.ui.FilteredMenu(opt_renderer, opt_domHelper)

Filtered menu class.

opt_renderer {goog.ui.MenuRenderer=}
Renderer used to render filtered menu; defaults to {@link goog.ui.MenuRenderer}.
opt_domHelper {goog.dom.DomHelper=}
Optional DOM helper.

The goog.ui.FilteredMenu.EventType Enum

Events fired by component. … more

.addChild(child, opt_render)

Inherited from goog.ui.Container .

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

child {goog.ui.Component}
The new child control.
opt_render {boolean=}
Whether the new child should be rendered immediately after being added (defaults to false).
@see
goog.ui.Component#addChildAt

.addChildAt(control, index, opt_render)

Inherited from goog.ui.Container .

Adds the control as a child of this container at the given 0-based index. Overrides {@link goog.ui.Component#addChildAt} by also updating the container's highlight index. Since {@link goog.ui.Component#addChild} uses {@link #addChildAt} internally, we only need to override this method.

control {goog.ui.Component}
New child.
index {number}
Index at which the new child is to be added.
opt_render {boolean=}
Whether the new child should be rendered immediately after being added (defaults to false).
returns {void}
Nada.
@see
goog.ui.Component#addChild

.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.

.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.Container .

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

element {Element}
Element to decorate.
returns {boolean}
True iff the element can be decorated.

.containsElement(element)

Inherited from goog.ui.Menu .

Returns whether the provided element is to be considered inside the menu for purposes such as dismissing the menu on an event. This is so submenus can make use of elements outside their own DOM.

element {Element}
The element to test for.
returns {boolean}
Whether the provided element is to be considered inside the menu.

.createDom()

.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.

.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.

.disposeInternal()

.enterDocument()

Inherited from goog.ui.Container .

Configures the container after its DOM has been rendered, and sets up event handling. Overrides {@link goog.ui.Component#enterDocument}.

.exitDocument()

Inherited from goog.ui.Container .

Cleans up the container before its DOM is removed from the document, and removes event handlers. Overrides {@link goog.ui.Component#exitDocument}.

.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.

.getAllowAutoFocus()

Inherited from goog.ui.Menu .

returns {boolean}
Whether the menu can automatically move focus to its key event target when it is set to visible.

.getAllowHighlightDisabled()

Inherited from goog.ui.Menu .

returns {boolean}
Whether the menu will highlight disabled menu items or skip to the next active item.

.getAllowMultiple()

returns {boolean}
Whether multiple items can be entered comma separated.

.getChild

Inherited from goog.ui.Container .

Overrides {@link goog.ui.Container#getChild} to make it clear that it only returns {@link goog.ui.Control}s.

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

.getChildAt

Inherited from goog.ui.Container .

Overrides {@link goog.ui.Container#getChildAt} to make it clear that it only returns {@link goog.ui.Control}s.

index {number}
0-based index.
returns {goog.ui.Control}
The child with the given ID; 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.

.getContentElement()

.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.

.getEnteredItems()

Gets a list of items entered in the search box.

returns {Array.<string>}
The entered items.

.getFilter()

Returns the filter string.

returns {string}
Current filter or an an empty string.

.getFilterFromIndex()

Returns the index of first item that is affected by the filter.

returns {number}
Index of first item that is affected by filter.

.getFilterInputElement()

Returns the filter input element.

returns {Element}
Input element.

.getFilterLabel()

returns {string}
The filter label.

.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.

.getHighlighted()

Inherited from goog.ui.Container .

Returns the currently highlighted item (if any).

returns {goog.ui.Control?}
Highlighted item (null if none).

.getHighlightedIndex()

Inherited from goog.ui.Container .

Returns the index of the currently highlighted item (-1 if none).

returns {number}
Index of the currently highlighted item.

.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.

.getKeyEventTarget()

Inherited from goog.ui.Container .

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

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

.getKeyHandler()

Inherited from goog.ui.Container .

Returns the keyboard event handler for this container, lazily created the first time this method is called. The keyboard event handler listens for keyboard events on the container's key event target, as determined by its renderer.

returns {goog.events.KeyHandler}
Keyboard event handler for this container.

.getModel()

Inherited from goog.ui.Component .

Returns the model associated with the UI component.

returns {*}
The model.

.getOpenItem()

Inherited from goog.ui.Container .

Returns the currently open (expanded) control in the container (null if none).

returns {goog.ui.Control?}
The currently open control.

.getOrientation()

Inherited from goog.ui.Container .

Returns the container's orientation.

returns {?goog.ui.Container.Orientation}
Container orientation.

.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.

.getPosition()

Inherited from goog.ui.Menu .

Gets the page offset of the menu, or null if the menu isn't visible

returns {goog.math.Coordinate?}
Object holding the x-y coordinates of the menu or null if the menu is not visible.

.getRenderer()

Inherited from goog.ui.Container .

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

returns {goog.ui.ContainerRenderer}
Renderer used by the container.

.handleBlur(e)

Inherited from goog.ui.Container .

Handles blur events raised when the container's key event target loses keyboard focus. The default implementation clears the highlight index.

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

.handleChildMouseEvents(e)

Inherited from goog.ui.Container .

Handles mouse events originating from nodes belonging to the controls hosted in the container. Locates the child control based on the DOM node that dispatched the event, and forwards the event to the control for handling.

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

.handleCloseItem(e)

Inherited from goog.ui.Container .

Handles CLOSE events dispatched by items in the container when they are closed.

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

.handleDocumentMouseUp(e)

Inherited from goog.ui.Container .

Handles mouseup events over the document. The default implementation clears the "mouse button pressed" flag.

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

.handleEnterItem(e)

Inherited from goog.ui.Menu .

Handles ENTER events raised by child controls when they are navigated to.

e {goog.events.Event}
ENTER event to handle.
returns {boolean}
Whether to prevent handleMouseOver from handling the event.

.handleFilterEvent(e)

Handles filter input events.

e {goog.events.BrowserEvent}
The event object.

.handleFocus(e)

Inherited from goog.ui.Container .

Handles focus events raised when the container's key event target receives keyboard focus.

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

.handleHighlightItem(e)

Inherited from goog.ui.Container .

Handles HIGHLIGHT events dispatched by items in the container when they are highlighted.

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

.handleKeyEvent(e)

Handles the menu's behavior for a key event. The highlighted menu item will be given the opportunity to handle the key behavior.

e {goog.events.KeyEvent}
A browser event.
returns {boolean}
Whether the event was handled.

.handleKeyEventInternal(e)

Inherited from goog.ui.Menu .

Attempts to handle a keyboard event; returns true if the event was handled, false otherwise. If the container is enabled, and a child is highlighted, calls the child control's {@code handleKeyEvent} method to give the control a chance to handle the event first.

e {goog.events.KeyEvent}
Key event to handle.
returns {boolean}
Whether the event was handled by the container (or one of its children).

.handleMouseDown(e)

Inherited from goog.ui.Container .

Handles mousedown events over the container. The default implementation sets the "mouse button pressed" flag and, if the container is focusable, grabs keyboard focus.

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

.handleOpenItem(e)

Inherited from goog.ui.Container .

Handles OPEN events dispatched by items in the container when they are opened.

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

.handleUnHighlightItem(e)

Inherited from goog.ui.Container .

Handles UNHIGHLIGHT events dispatched by items in the container when they are unhighlighted.

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.

.hasPersistentVisibility(child)

Returns whether the specified child should be affected (shown/hidden) by the filter criteria.

child {goog.ui.Component}
Menu item to check.
returns {boolean}
Whether the menu item is persistent.

.highlightFirst()

Inherited from goog.ui.Container .

Highlights the first highlightable item in the container

.highlightLast()

Inherited from goog.ui.Container .

Highlights the last highlightable item in the container.

.highlightNext()

Inherited from goog.ui.Container .

Highlights the next highlightable item (or the first if nothing is currently highlighted).

.highlightNextPrefix(charStr)

Inherited from goog.ui.Menu .

Highlights the next item that begins with the specified string. If no (other) item begins with the given string, the selection is unchanged.

charStr {string}
The prefix to match.
returns {boolean}
Whether a matching prefix was found.

.highlightPrevious()

Inherited from goog.ui.Container .

Highlights the previous highlightable item (or the last if nothing is currently highlighted).

.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.

.isDisposed()

Inherited from goog.Disposable .

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

.isEnabled()

Inherited from goog.ui.Container .

Returns true if the container is enabled, false otherwise.

returns {boolean}
Whether the container is enabled.

.isFocusable()

Inherited from goog.ui.Container .

Returns true if the container is focusable, false otherwise. The default is true. Focusable containers always have a tab index and allocate a key handler to handle keyboard events while focused.

returns {boolean}
Whether the component is focusable.

.isFocusableChildrenAllowed()

Inherited from goog.ui.Container .

Returns true if the container allows children to be focusable, false otherwise. Only effective if the container is not focusable.

returns {boolean}
Whether children should be focusable.

.isInDocument()

Inherited from goog.ui.Component .

Determines whether the component has been added to the document.

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

.isMouseButtonPressed()

Inherited from goog.ui.Container .

Returns true if the mouse button is pressed, false otherwise.

returns {boolean}
Whether the mouse button is pressed.

.isOpenFollowsHighlight()

Inherited from goog.ui.Container .

returns {boolean}
Whether highlighting a child component should also open it.

.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.

.isVisible()

Inherited from goog.ui.Container .

Returns true if the container's visibility is set to visible, false if it is set to hidden. A container that is set to hidden is guaranteed to be hidden from the user, but the reverse isn't necessarily true. A container 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 container is set to be 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.

.openingCoords {goog.math.Coordinate|undefined}

Inherited from goog.ui.Menu .

Coordinates of the mousedown event that caused this menu to be made visible. Used to prevent the consequent mouseup event due to a simple click from activating a menu item immediately. Considered protected; should only be used within this package or by subclasses.

.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(control, opt_unrender)

Inherited from goog.ui.Container .

Removes a child control. Overrides {@link goog.ui.Component#removeChild} by updating the highlight index. Since {@link goog.ui.Component#removeChildAt} uses {@link #removeChild} internally, we only need to override this method.

control {string|goog.ui.Component}
The ID of the child to remove, or the control itself.
opt_unrender {boolean=}
Whether to call {@code exitDocument} on the removed control, and detach its DOM from the document (defaults to false).
returns {goog.ui.Control}
The removed control, 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

.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.

.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.

.setAllowAutoFocus(allow)

Inherited from goog.ui.Menu .

Sets whether the menu can automatically move focus to its key event target when it is set to visible.

allow {boolean}
Whether the menu can automatically move focus to its key event target when it is set to visible.

.setAllowHighlightDisabled(allow)

Inherited from goog.ui.Menu .

Sets whether the menu will highlight disabled menu items or skip to the next active item.

allow {boolean}
Whether the menu will highlight disabled menu items or skip to the next active item.

.setAllowMultiple(b)

Sets whether multiple items can be entered comma separated.

b {boolean}
Whether multiple items can be entered.

.setEnabled(enable)

Inherited from goog.ui.Container .

Enables/disables the container based on the {@code enable} argument. Dispatches an {@code ENABLED} or {@code DISABLED} event prior to changing the container's state, which may be caught and canceled to prevent the container from changing state. Also enables/disables child controls.

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

.setFilter(str)

Sets the filter string.

str {?string}
Filter string.

.setFilterFromIndex(index)

Sets the index of first item that should be affected by the filter. Menu items with a lower index will not be affected by the filter.

index {number}
Index of first item that should be affected by filter.

.setFilterLabel(label)

Sets the filter label (the label displayed in the filter input element if no text has been entered).

label {?string}
Label text.

.setFocusable(focusable)

Inherited from goog.ui.Container .

Sets whether the container is focusable. The default is true. Focusable containers always have a tab index and allocate a key handler to handle keyboard events while focused.

focusable {boolean}
Whether the component is to be focusable.

.setFocusableChildrenAllowed(focusable)

Inherited from goog.ui.Container .

Sets whether the container allows children to be focusable, false otherwise. Only effective if the container is not focusable.

focusable {boolean}
Whether the children should be focusable.

.setHighlighted(item)

Inherited from goog.ui.Container .

Highlights the given item if it exists and is a child of the container; otherwise un-highlights the currently highlighted item.

item {goog.ui.Control}
Item to highlight.

.setHighlightedIndex(index)

Sets the highlighted index, unless the HIGHLIGHT event is intercepted and cancelled. -1 = no highlight. Also scrolls the menu item into view.

index {number}
Index of menu item to highlight.

.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.

.setKeyEventTarget(element)

Inherited from goog.ui.Container .

Attaches an element on which to listen for key events.

element {Element|undefined}
The element to attach, or null/undefined to attach to the default element.

.setModel(obj)

Inherited from goog.ui.Component .

Sets the model associated with the UI component.

obj {*}
The model.

.setMouseButtonPressed(pressed)

Inherited from goog.ui.Container .

Sets or clears the "mouse button pressed" flag.

pressed {boolean}
Whether the mouse button is presed.

.setOpenFollowsHighlight(follow)

Inherited from goog.ui.Container .

Sets whether highlighting a child component should also open it.

follow {boolean}
Whether highlighting a child component also opens it.

.setOrientation(orientation)

Inherited from goog.ui.Container .

Sets the container's orientation.

orientation {goog.ui.Container.Orientation}
Container orientation.

.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).

.setPersistentVisibility(child, persistent)

Sets whether the specified child should be affected (shown/hidden) by the filter criteria.

child {goog.ui.Component}
Child to change.
persistent {boolean}
Whether the child should be persistent.

.setPosition(x, opt_y)

Inherited from goog.ui.Menu .

Sets the position of the menu relative to the view port.

x {number|goog.math.Coordinate}
Left position or coordinate obj.
opt_y {number=}
Top position.

.setRenderer(renderer)

Inherited from goog.ui.Container .

Registers the given renderer with the container. Changing renderers after the container has already been rendered or decorated is an error.

renderer {goog.ui.ContainerRenderer}
Renderer used by the container.

.setRightToLeft(rightToLeft)

Inherited from goog.ui.Component .

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.

.setVisible(opt_e)

Shows or hides the container. Does nothing if the container already has the requested visibility. Otherwise, dispatches a SHOW or HIDE event as appropriate, giving listeners a chance to prevent the visibility change.

opt_e {goog.events.Event=}
Mousedown event that caused this menu to be made visible (ignored if show is false).
returns {boolean}
Whether the visibility was changed.

.wasDecorated()

Inherited from goog.ui.Component .

returns {boolean}
Whether the component was decorated.