controllerListButton
listButton(list, action, action_pos, action_step,
when_clicked, when_no_progress, when_on_border,
back_delay, alt_class)
listButton.messages = [update, click]
listButton.events = [click, no_progress,
border_reached, border_left]
Description
Adds functionality to a button (or any element) that makes it behave as a commanding button to a supplied list() controller.
The button, upon being clicked, sends a message supplied by parameter action to the list.
The parameters when_clicked, when_no_progress and when_on_border
tell what should happen to the button when clicked or when the list's current focus reaches the list border or tries to pass it.
In these cases, the listButton() controller can make the button element disabled, change its styling or fire an event
that can be handled by other controllers (that will perform some hiding animation, for example).
Does not apply any transforms.
Parameters
Visit page Controller # Common Parameters for documentation on the parameters, common to all controllers:
id,
paused and
disabled.
Parameters of listButton():
- list
-
A string supplying the controller ID of the source list of items, to which messages are sent and from which events are received.
If the
list()controller is attached on another element, then the string should contain the space-separated element's and controller's IDs:
list: "element_id list_id"Default value: "" - action
-
Message to send to the
list()controller upon the button being clicked (or receiving messageclick). The supported messages arefocus_xxx,selectandunselect. Some of these messages require a message parameterposorstep, which is set via the parameteraction_posoraction_step, respectively. Default value: "" - action_pos
-
When the button's action (i.e. the message sent to the list) is
focus_pos,selectorunselect, then supply the required message paramposhere. Default value: -1 - action_step
-
When the button's action (i.e. the message sent to the list) is
focus_step, then supply the required message paramstephere. Default value: 0 - when_clicked
-
Tells what the button should do when clicked, apart from sending the message to the
list()controller. Supply a string containing space-separated commands, where the following commands are supported:fire- fire an eventclick,disable- set the element'sdisabledproperty totrue, and set it tofalseafter a delay supplied via paramback_delay,change_class- add a styling class to the button (class name is supplied via paramalt_class), and after a delay supplied via paramback_delayremove the added class.
- when_no_progress
-
Tells what the button should do when the list fires an event
no_nextorno_prev(fired when an attempt is made to focus outside the list range in the respective direction).
Note that when this button'sactionparam is"focus_next", the button will react only tono_nextlist events, and if the button'sactionparam is"focus_prev", the button will react only tono_prevlist events.
Supply a string containing space-separated commands, where the following commands are supported:fire- fire an eventno_progress,disable- set the element'sdisabledproperty totrue, and set it tofalseafter a delay supplied via paramback_delay,change_class- add a styling class to the button (class name is supplied via paramalt_class), and after a delay supplied via paramback_delayremove the added class.
- when_on_border
-
Tells what the button should do when the list fires an event
last_reached,first_reachedorborder_left(fired when the list's focus reaches or leaves the last/first item, respectively).
Note that when this button'sactionparam is"focus_next", the button will react only tolast_reachedandborder_leftlist events, and if the button'sactionparam is"focus_prev", the button will react only tofirst_reachedandborder_leftlist events.
Supply a string containing space-separated commands, where the following commands are supported:fire- fire eventsborder_reachedandborder_left,disable- set the element'sdisabledproperty totruewhen the border (i.e. first or last item) is reached, and set it tofalsewhen the border is left,change_class- add a styling class to the button (class name is supplied via paramalt_class) when the border is reached, and remove the added class when the border is left.
- back_delay
-
Delay in milliseconds before the
disableandchange_classeffects are undone afterclickandno_progressevents. Default value: 200 - alt_class
-
Name of a style class to be applied by the
change_classcommand. Default value: ""
Accepted Messages
Visit page Controller # Common Messages for documentation on the messages, accepted by all controllers:
pause,
unpause,
enable,
disable,
params and
remove.
Messages accepted by listButton():
- update
-
In the rare case when the
list()controller is not created at the time of event-initializing of thelistButton()controller, the latter will not create its event listeners on the list. Send this message when thelist()controller is instantiated, to add the event listeners on it, effectively "linking" the button to the list. Message params: none - click
- Tell the controller that the button is clicked. Message params: none
Generated Events
Visit page Controller # Common Events for documentation on the events, generated by all controllers:
frame,
remove,
paused,
unpaused
enabled and
disabled.
Events fired by listButton():
- click
-
Fired upon the button being clicked or the controller receiving message
clickfrom the outside. The event is fired only if thewhen_clickedparam contains the command"fire". Event params: none - no_progress
-
Fired when an attempt is made to focus outside the list items' range in either direction.
The event is fired only if the
when_no_progressparam contains the command"fire". See the paramter's description for more details. Event params: none - border_reached
-
Fired when the focus reaches the first or last item in the list.
The event is fired only if the
when_on_borderparam contains the command"fire". See the paramter's description for more details. Event params: none - border_left
-
Fired when the focus leaves the first or last item in the list.
The event is fired only if the
when_on_borderparam contains the command"fire". See the paramter's description for more details. Event params: none
Interaction with DOM
- Transforms: Does not apply any CSS transforms.
- CSS: Works with any styling. Modifies the button element's
disabledandclassListproperties ifdisableandchange_classcommands are present in thewhen_xxxcontroller parameters. - Events: Sets a DOM event listener for the
clickevent on the button element, and also sets a behave3d listener for all events on thelist()controller.
Changes Log
- Controller introduced in v.0.80