ToolBar

A tool bar component that is usually used at the top of window and can hold Label, Button, TextField, and Separator to display useful tools for a user.

Tool bar can be draggable and can be detached and displayed in a separate dedicated window. It can also be in horizontal (default) and vertical orientation.

Constructor

new ToolBar()

Create an instance of ToolBar component object.

Classes

ToolBar

Methods

addSpacer(width, height) → {ToolBar}

Add an invisible spacer of specified width and height.

Parameters:
NameTypeDescription
widthnumber

Width of the spacer block

heightnumber

Height of the spacer block

Returns:

Returns this ToolBar component for method chaining.

Type: 
ToolBar

alignment(alignmentopt) → {string|ToolBar}

Set or get alignment of components within toolbar.

Parameters:
NameTypeAttributesDescription
alignmentstring<optional>

"leading|trailing|left|center|right"

Returns:

If no parameters were passed, current alignment is returned; otherwise this Toolbar component is returned for method chaining.

Type: 
string | ToolBar

attached(attachedopt, floating_positionopt) → {boolean|ToolBar}

Sets or gets boolean whether the toolbar is attached to main Window. Has no affect if not attached to a Window yet.

Parameters:
NameTypeAttributesDescription
attachedboolean<optional>

true to attach, false to detach from Window component the ToolBar is added to.

floating_positionObject<optional>

Position on screen where toolbar should float {x:number, y:number}.

Returns:

If no parameters were passed, current state is returned; otherwise this Toolbar component is returned for method chaining.

Type: 
boolean | ToolBar

detachable(detachableopt) → {boolean|ToolBar}

Sets of gets whether the ToolBar can be detached from the Window it was added to.

Parameters:
NameTypeAttributesDescription
detachableboolean<optional>

true to enable detaching, false to disable.

Returns:

If no parameters were passed, current value is returned, otherwise this Toolbar component is returned for method chaining.

Type: 
boolean | ToolBar

onDockEvents(callbackopt, removeopt) → {ToolBar|Array.<function()>}

Gets, registers or unregisters a docking event handler function. This event handler is called when the ToolBar gets attached/detached.

Parameters:
NameTypeAttributesDefaultDescription
callbackfunction<optional>

The event handler function. Receives an event object.

removeboolean<optional>
false

Set to true to unregister the event handler.

Returns:

An array of handler functions if no arguments are passed, otherwise this component for method chaining.

Type: 
ToolBar | Array.<function()>
Example
// Event object format:
const e = {
  target: object,                        // The ToolBar component that triggered the event.
  type: string,                          // "attached", "detached".
  interactive: boolean                   // Only when type is "update". `true` when update was made by the user interacting with the GUI. `false` when update was made programmatically.
  orientation: Orientation               // current orientation
  location: string                       // "top", "bottom", "left", "right". Only when `e.interactive` is `true`.
  mouseX: number                         // Mouse X position relative to Window's content area.  Only when `e.interactive` is `true`.
  mouseY: number                         // Mouse Y position relative to Window's content area.  Only when `e.interactive` is `true`.
};

orientation(orientationopt) → {Orientation|ToolBar}

Sets or gets vertical or horizontal orientation of the ToolBar.

Parameters:
NameTypeAttributesDescription
orientationOrientation<optional>

One of these values: Orientation.Horizontal (default) or Orientation.Vertical

Returns:

If no parameters were passed, current orientation is returned; otherwise this Toolbar component is returned for method chaining.

Type: 
Orientation | ToolBar

padding(padding) → {number|ToolBar}

Sets or gets a padding size between edge of the component and items inside it, and spacing between items.

Parameters:
NameTypeDescription
paddingnumber

Padding size in pixels.

Returns:

If no parameters were passed, current padding is returned; otherwise this Toolbar component is returned for method chaining.

Type: 
number | ToolBar