new ButtonArray(optionsopt)
TK.ButtonArray is a list of (TK.Button)s, arranged either vertically or horizontally. TK.ButtonArray is able to add arrow buttons automatically if the overal size is less than the width/height of the buttons list.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
Object |
<optional> |
{ } | An object containing initial options. |
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options.buttons |
Array.<(Object|String)> |
<optional> |
[] | A list of
button options objects or label strings which is converted to
button instances on init. If |
options.auto_arrows |
Boolean |
<optional> |
true | Set to |
options.direction |
String |
<optional> |
"horizontal" | The layout of the button list, either "horizontal" or "vertical". |
options.show |
Integer | TK.Button |
<optional> |
-1 | The TK.Button
to scroll to and highlight, expects either the button index starting
from zero or the TK.Button instance itself. Set to |
options.scroll |
Integer |
<optional> |
0 | Offer scrollbars for generic scrolling. This reduces performance because movement is done in JS instead of (pesumably accelerated) CSS transitions. 0 for standard behavior, n > 0 is handled as milliseconds for transitions. |
options.button_class |
Object |
<optional> |
TK.Button | A class to be used for instantiating the buttons. |
Source: |
Extends
Members
_clip :HTMLDivElement
A clipping area containing the list of TK.Buttons.
Has class toolkit-clip
.
Source: |
_container :HTMLDivElement
A container for all the TK.Buttons.
Has class toolkit-container
.
Source: |
_next :HTMLDivElement
The HTMLDivElement of the next TK.Button.
Source: |
_prev :HTMLDivElement
The HTMLDivElement of the previous TK.Button.
Source: |
buttons :Array
An array holding all TK.Buttons.
Source: |
element :HTMLDivElement
The main DIV container.
Has class toolkit-buttonarray
.
Overrides: | |
Source: |
next :TK.Button
The next arrow TK.Button instance.
Source: |
prev :TK.Button
The previous arrow TK.Button instance.
Source: |
Methods
add_button(options, positionopt) → {TK.Button}
Adds a TK.Button to the TK.ButtonArray.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object | string | An object containing options for the TK.Button to add or a string for the label. |
|
position |
integer |
<optional> |
The position to add the TK.Button
to. If |
Source: |
Returns:
The TK.Button instance.
- Type
- TK.Button
add_buttons(options)
Adds an array of buttons to the end of the list.
Parameters:
Name | Type | Description |
---|---|---|
options |
Array.<(string|object)> | An Array containing objects with options for the buttons (see TK.Button for more information) or strings for the buttons labels. |
Source: |
current() → {TK.Button}
The currently active button.
Source: |
Returns:
The active TK.Button or null, if none is selected.
- Type
- TK.Button
remove_button(button)
Removes a TK.Button from the TK.ButtonArray.
Parameters:
Name | Type | Description |
---|---|---|
button |
integer | TK.Button | button index or the TK.Button instance to be removed. |
Source: |
Methods inherited from TK.Container
append_child(child)
Appends child.element
to the container element and
registers child
as a child widget.
append_children(children)
Calls TK.Container#append_child for an array of widgets.
force_hide()
Immediately switches the display state of this container to hide
.
Unlike TK.Container#hide this method does not perform the hiding transition
and immediately modifies the DOM by setting the toolkit-hide
class.
force_show()
Immediately switches the display state of this container to show
.
Unlike TK.Container#hide this method does not perform the hiding transition
and immediately modifies the DOM by setting the toolkit-show
class.
hide()
Starts the transition of the display_state
to hide
.
hide_child(child)
Switches the hidden state of a child to hidden
.
The argument is either the child index or the child itself.
show()
Starts the transition of the display_state
to show
.
show_child(child)
Switches the hidden state of a child to shown
.
The argument is either the child index or the child itself.
toggle_child(child)
Toggles the hidden state of a child. The argument is either the child index or the child itself.
Methods inherited from TK.Widget
add_child(child)
Registers a widget as a child widget. This method is used to build up the widget tree. It does not modify the DOM tree.
add_children(a)
Registers an array of widgets as children.
all_children()
Returns an array of all children.
enable_draw()
Schedules this widget for drawing.
get_style()
Returns the computed style of this widgets DOM element.
hidden()
Returns the current hidden status.
remove_child(child)
Removes a child widget. Note that this method only modifies the widget tree and does not change the DOM.
remove_children(a)
Removes an array of children.
set(key, value)
Sets an option.
set_style()
Sets a CSS style property in this widgets DOM element.
toggle_hidden()
TK.Toggle the hidden status. This is equivalent to calling hide() or show(), depending on the current hidden status of this widget.
visible_children()
Returns an array of all visible children.
widgetize()
Set the DOM elements of this widgets. This method is usually only used internally. Basically it means to add the id from options and set a basic CSS class. If delegate is true, basic events will be delegated from the element to the widget instance if classify is true, CSS functions will be bound to the widget instance.
Methods inherited from TK.Base
add_event(event, func, prevent, stop)
Register an event handler.
add_events(events, func)
Add multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.
delegate_events(element) → {HTMLElement}
Delegates all occuring DOM events of a specific DOM node to the widget. This way the widget fires e.g. a click event if someone clicks on the given DOM node.
destroy()
Destroys all event handlers and the options object.
fire_event(event, …args)
Fires an event.
fire_events(events)
Fires several events.
get(key)
Get the value of an option.
has_event_listeners(event) → {boolean}
Test if the event descriptor has some handler functions in the queue.
remove_event(event, fun)
Removes the given function from the event queue. If it is a native DOM event, it removes the DOM event listener as well.
remove_events(events, func)
Remove multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.
set_options(optionsopt)
Merges a new options object into the existing one, including deep copies of objects. If an option key begins with the string "on" it is considered as event handler. In this case the value should be the handler function for the event with the corresponding name without the first "on" characters.
userset(key, value)
Sets an option by user interaction. Emits the userset
event. The userset
event can be cancelled (if an event handler
returns false
), in which case the option is not set.
Returns true
if the option was set, false
otherwise. If the option was set, it will emit a useraction
event.
Events
added
A TK.Button was added to the TK.ButtonArray.
Parameters:
Name | Type | Description |
---|---|---|
button |
TK.Button | The TK.Button which was added to TK.ButtonArray. |
Source: |
changed
Is fired when a button is activated.
Parameters:
Name | Type | Description |
---|---|---|
button |
TK.Button | The TK.Button which was clicked. |
id |
int | the ID of the clicked TK.Button. |
Source: |
removed
A TK.Button was removed from the TK.ButtonArray.
Parameters:
Name | Type | Description |
---|---|---|
button |
TK.Button | The TK.Button instance which was removed. |
Source: |
Events inherited from TK.Container
hide
Is fired when the container is hidden.
show
Is fired when the container is shown.
Events inherited from TK.Widget
GenericDOMEvents
Generic DOM events. Please refer to W3Schools for further details.
classified
Is fired when a widget is classified.
destroy
Is fired when a widget is destroyed.
doubleclick
Is fired after a double click appeared. Set dblclick
to 0 to
disable click event handling.
initialized
Is fired when a widget is initialized.
redraw
Is fired when a redraw is executed.
resize
The resize
event is emitted whenever a widget is being resized. This event can
be used to e.g. measure its new size. Note that some widgets do internal adjustments after
the resize
event. If that is relevant, the TK.Widget#resized event can
be used, instead.
resized
The resized
event is emitted after each rendering frame, which was triggered by
a resize event.
set
The set
event is emitted when an option was set using the TK.Widget#set
method. The arguments are the option name and its new value.
Note that this happens both for user interaction and programmatical option changes.
stylized
Is fired when a widget is stylized.
visibility
Is fired when the visibility state changes. The first argument
is the visibility state, which is either true
or false
.
widgetize
Is fired when a widget is widgetized.
Events inherited from TK.Base
delegated
Is fired when an element is delegated.
set_[option]
Is fired when an option is set.