Home

# Class goog.ui.editor.ToolbarController

A class for managing the editor toolbar. Acts as a bridge between a {@link goog.editor.Field} and a {@link goog.ui.Toolbar}. The {@code toolbar} argument must be an instance of {@link goog.ui.Toolbar} or a subclass. This class doesn't care how the toolbar was created. As long as one or more controls hosted in the toolbar have IDs that match built-in {@link goog.editor.Command}s, they will function as expected. It is the caller's responsibility to ensure that the toolbar is already rendered or that it decorates an existing element.

extends goog.events.EventTarget

Instance Method Summary
| `blur()` Programmatically blurs the editor toolbar, un-highlighting the currently highlighted item, and closing the currently open menu (if any).

`disposeInternal()`

Unattach listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners, it should be something like this:

    MyClass.prototype.disposeInternal = function() {
    MyClass.superClass_.disposeInternal.call(this);
    // Dispose logic for MyClass
    };

| `getCommand(string id) ⇒ string` Returns the {@link goog.editor.Command} constant that corresponds to the given Closure component ID. Subclasses may override this method if they want to use a custom mapping scheme from controls to commands.
| `getComponentId(string command) ⇒ string` Returns the Closure component ID of the control that corresponds to the given {@link goog.editor.Command} constant. Subclasses may override this method if they want to use a custom mapping scheme from commands to controls.
| `getField() ⇒ !goog.editor.Field` Returns the field instance managed by the toolbar. Useful for classes that extend {@code goog.ui.editor.ToolbarController}.
| `getHandler() ⇒ !goog.events.EventHandler` Returns the event handler object for the editor toolbar. Useful for classes that extend {@code goog.ui.editor.ToolbarController}.
| `getToolbar() ⇒ !goog.ui.Toolbar` Returns the toolbar UI component that manages the editor. Useful for classes that extend {@code goog.ui.editor.ToolbarController}.
| `handleAction(?goog.events.Event e)` Handles {@code ACTION} events dispatched by toolbar buttons in response to user actions by executing the corresponding field command.
| `isEnabled() ⇒ boolean`
| `isVisible() ⇒ boolean`
| `setEnabled(boolean enabled)` Enables or disables the toolbar.
| `setVisible(boolean visible)` Shows or hides the toolbar.
| `updateToolbar(?goog.events.Event e)` Updates the toolbar in response to editor events. Specifically, updates button states based on {@code COMMAND_VALUE_CHANGE} events, reflecting the effective formatting of the selection.
| `updateToolbarFromState(?Object state)` Updates the toolbar to reflect a given state.