Home

# Library goog.ui.editor.ToolbarFactory

Function Summary
| `addFont(!goog.ui.Select button, string caption, string value)` Adds a menu item to the given font menu button. The first font listed in the {@code value} argument is considered the font ID, so adding two items whose CSS style starts with the same font may lead to unpredictable results.
| `addFontSize(!goog.ui.Select button, string caption, number value)` Adds a menu item to the given font size menu button. The {@code value} argument must be a legacy HTML font size in the 0-7 range.

`addFontSizes(!goog.ui.Select button, !Array sizes)`

Bulk-adds font sizes to the given font size menu button. The argument must be an array of font size descriptor objects, each of which must have the following attributes:

- {@code caption} - Caption to show in the font size menu (e.g. 'Huge')
- {@code value} - Value for the corresponding HTML font size (e.g. 6)

`addFonts(!goog.ui.Select button, !Array fonts)`

Bulk-adds fonts to the given font menu button. The argument must be an array of font descriptor objects, each of which must have the following attributes:

- {@code caption} - Caption to show in the font menu (e.g. 'Tahoma')
- {@code value} - Value for the corresponding 'font-family' CSS style (e.g. 'Tahoma, Arial, sans-serif')

| `addFormatOption(!goog.ui.Select button, string caption, ?goog.dom.TagName tag)` Adds a menu item to the given "Format block" menu button.

`addFormatOptions(!goog.ui.Select button, !Array formats)`

Bulk-adds format options to the given "Format block" menu button. The argument must be an array of format option descriptor objects, each of which must have the following attributes:

- {@code caption} - Caption to show in the menu (e.g. 'Minor heading')
- {@code command} - Corresponding {@link goog.dom.TagName} (e.g. 'H4')

| `createContent_(?goog.ui.ControlContent caption, string= opt_classNames, ?goog.dom.DomHelper= opt_domHelper) ⇒ !Element` Creates a new DIV that wraps a button caption, optionally applying CSS class names to it. Used as a helper function in button factory methods.
| `getLegacySizeFromPx(number px) ⇒ number` Converts a pixel font size specification into an equivalent legacy size. For example, {@code font-size: 32px;} is {@code <font size="6">}, etc. If the given pixel size doesn't exactly match one of the legacy sizes, -1 is returned.
| `getPrimaryFont(string fontSpec) ⇒ string` Takes a font spec (e.g. "Arial, Helvetica, sans-serif") and returns the primary font name, normalized to lowercase (e.g. "arial").
| `getPxFromLegacySize(number fontSize) ⇒ number` Converts a legacy font size specification into an equivalent pixel size. For example, {@code <font size="6">} is {@code font-size: 32px;}, etc.
| `makeButton(string id, string tooltip, ?goog.ui.ControlContent caption, string= opt_classNames, ?goog.ui.ButtonRenderer= opt_renderer, ?goog.dom.DomHelper= opt_domHelper) ⇒ !goog.ui.Button` Creates a toolbar button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's caption element.

`makeColorMenuButton(string id, string tooltip, ?goog.ui.ControlContent caption, string= opt_classNames, ?goog.ui.ColorMenuButtonRenderer= opt_renderer, ?goog.dom.DomHelper= opt_domHelper) ⇒ !goog.ui.ColorMenuButton`

Creates a color menu button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's caption element. The button is created with a default color menu containing standard color palettes.

`makeMenuButton(string id, string tooltip, ?goog.ui.ControlContent caption, string= opt_classNames, ?goog.ui.ButtonRenderer= opt_renderer, ?goog.dom.DomHelper= opt_domHelper) ⇒ !goog.ui.MenuButton`

Creates a menu button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's caption element. The button returned doesn't have an actual menu attached; use {@link goog.ui.MenuButton#setMenu} to attach a {@link goog.ui.Menu} to the button.

`makeSelectButton(string id, string tooltip, ?goog.ui.ControlContent caption, string= opt_classNames, ?goog.ui.MenuButtonRenderer= opt_renderer, ?goog.dom.DomHelper= opt_domHelper) ⇒ !goog.ui.Select`

Creates a select button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's root element. The button returned doesn't have an actual menu attached; use {@link goog.ui.Select#setMenu} to attach a {@link goog.ui.Menu} containing {@link goog.ui.Option}s to the select button.

| `makeToggleButton(string id, string tooltip, ?goog.ui.ControlContent caption, string= opt_classNames, ?goog.ui.ButtonRenderer= opt_renderer, ?goog.dom.DomHelper= opt_domHelper) ⇒ !goog.ui.Button` Creates a toggle button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's caption element. The button returned has checkbox-like toggle semantics.
| `makeToolbar(!Array items, !Element elem, boolean= opt_isRightToLeft) ⇒ !goog.ui.Toolbar` Creates a {@link goog.ui.Toolbar} containing the specified set of toolbar buttons, and renders it into the given parent element. Each item in the {@code items} array must a {@link goog.ui.Control}.